Forums Register Login

EJB and JDBC in SessionBean

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
Tiago,
If you are using two ways to store data in the same transaction, you need to use 2 phase commit (XA Driver.)
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Well, I'm using JBoss...
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 914 times.
Similar Threads
General Questions on EJB
J2EE Design Question -- Am I On The Right Track?
EJB-QL 2.0 & aggregate COUNT() functionality
Session & Entity Beans
usage of entity and session beans in combination?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:56:04.