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

EJB 3.0 insert data to more than 2 tables with one transaction

 
nis siv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

We are using EJB3.0 + entities
in our project we need to save data to 3 to 5 tables.
They have relationship(one to many like ...).

can anyone please suggest a method to insert data to all the tables using one transaction .

(instead insert in master then merge detail then child of second ).


Thanks,

Nis
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't follow the question - if your DAO code is called from an EJB method that uses CMT it will all be in one transaction. Am I missunderstanding what you are asking?
 
nis siv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if there is some master child relationship between tables using the named query we can get all the data satisfying our criteria .like this is there any facility to insert the values using named query
 
Moayad Abu Jaber
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should put cascade attribute in your relationship annotation.

you can see this site he explain what you want exactly.
 
nis siv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply !!
Do you have any other samples .
using list and all
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic