• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

If condition not working in transaction

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?






.>
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic