Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB and JDBC in SessionBean  RSS feed

 
Tiago Fernandez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey fellas,

I'm working in a system that uses EJB and JDBC for persistence. I don't have Entity Beans for all the tables, so let's say that when the busines logic requires data creation between 2 tables (1 to N): the first got an Entity Bean, and the other don't. When my Session Bean is called to persist data using this 2 tables, should I use the Entity Bean to store data into the first table, and JDBC to store into the second one, right?

The issue is that I'm getting deadlock into the database when I do that, the application get frozen and nothing happens. I think it could be a problem with the transactions...

I solved that extracting the business logic from the Session Bean and inserting into my Data Access Object (saving firt using the Entity Bean, and after JDBC with different method from Session Bean), but I don't think that's the best way to do it.

Do you have any idea to do it better?

Thanks!
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37222
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiago,
If you are using two ways to store data in the same transaction, you need to use 2 phase commit (XA Driver.)
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is going to be very dependent on the EJB container you are using. If you'd tell us that we might be able to give some better advice.

Kyle
 
Tiago Fernandez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm using JBoss...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!