File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If condition not working in transaction

 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

take a look at the following code:

In the "Insert new Recipients" bit of the code I am trying to introduce an if statement which checks the size of recipientIds. It will run preparedstatement3 only if that list has atleast 1 value. Now, when I run it and I enter nothing for the recipients I expect it to insert the data into the other tables and skip the recipients table, but that isnt the case. See the error ouput below:


Does anyone know why this is happening ?






.>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your recipientIds collection looks like it contains invalid data, hence your foreign key constraint fails. How/when do you populate it?
 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats the problem, it contains no data so it shouldn't execute that chunck of code.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well clearly it does contain data. I'd check the code where its set. Stick in a break point and see whats happening.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic