Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If condition not working in transaction

 
shaf maff
Ranch Hand
Posts: 180
  • 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
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic