views:

100

answers:

2

hi, i am using hibernate but i want to add an application that is using hibernate. the problem that i am facing is when i want to perform global transaction on that combined application. i am using weblogic as container, now the problem is that hibernate created its own connection, i want that toplink should use that connection only... can any one tell me how can i achieve that?????

A: 

Are you concerned about multiple connections or combining transactions? If you want your toplink code and your hibernate code to share transactions you're probably going to have to look at JTA to combine them into a distributed transaction. Otherwise, I'm unclear on what it is you're trying to accomplish

Jherico
see, i mean to say that my application is using hibernate, now i want to call application that is using toplink, problem i am facing is with when i am trying to achieve global transaction. so i thought that if hibernate and toplink use the same connection then it wud be possible for me to achive global transaction..
Mrityunjay
That's not really how transactions work. Investigate distributed transactions and how to integrate both toplink and hibernate into them. I recommend atomikos as an embeddable JTA manager
Jherico
A: 

I'd suggest keeping the Hibernate and TopLink worlds separate and use one EJB Session bean for the Hibernate side of things and another EJB Session bean for the TopLink side of things.

Use container managed transactions and let the WebLogic server take care of the commit across both session bean calls. You may need one data source + connection pool for the TopLink work and a different data source + connection pool for the Hibernate work as well.

This way you have proper architectural separation between the two ORM technologies. I suspect that trying to use the same connection from the TopLink work and passing it to Hibernate (or vice versa) won't work because once one tool has called commit then the other tool can't call rollback :-)

Is you do things at the EJB layer it will be easier than mucking about with JTA directly. The container should take care of the JTA stuff for you.

Richard Perfect
ya this is what i want. i will always say commit from hibernate not from toplink. see some cases are working for me. but there is only one case that is creating problem. see, flow is like this, first i call hibernate , then from hibernate i call toplink, then control returns to hibernate for some processing and at last there is a commit from hibernate. this is my schenario. now if there is some problem in hibernate but toplink worked fine , then also according to me complete transaction must rollback but toplink gets commited adb hibernate gets rollbacked.
Mrityunjay
i guess the problem is with the toplink because i create a connection of my own and then i pass that to hibernate to use, but toplink creates connection of its own... so i was asking whether there is a way i can give my created connection to toplink, so that tplink can work on that
Mrityunjay