-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Issue with Hibernate transaction in CMT
PostPosted: Tue Jun 15, 2010 9:29 am 
Newbie

Joined: Mon Jun 14, 2010 7:37 am
Posts: 7
Hi All,

I have a secnario like this:

CMT with Hibernate
1. Insert a record into table1 with JXP
2. execute select query with Hibernate on table1 to fetch the record inserted in the above table.
3. Result: No records present in the table ------------> (1)
4. close the hibernate session/tx
Below is the code snippet:
CustomService(CMT) {
PartyRole (CMT) -> insert record
Hibernate -> select record
}


Only with Hibernate
1. Insert a record into table2 using session.save(obj)
2. execute select query on table2 to fetch the record inserted in the above table.
3. 1 record present in the table.-------------------- > (2)
4. commit/close the transaction
Below is the code snippet
create() method: Complete Hibernate
{
open session/transaction
insert record;
select record; -> able to fetch the record.
commit and close ;
}

With the above findings, For the first one....I understood that Hibernate is not identifying any db changes performed by CMT.
In the second example, insert and select done by hibernate. so i am able to fetch the records which is not committed.

Can you help, Is there any way to specify hibernate to make use of the CMT transaction. how it should identify the changes done by CMT.

In Hibernate code I have tried with openSession() as well as currentSession. but did not work.

Please help me in this.

-Kiran


Top
 Profile  
 
 Post subject: Re: Issue with Hibernate transaction in CMT
PostPosted: Tue Jun 29, 2010 3:42 am 
Newbie

Joined: Mon Jun 14, 2010 7:37 am
Posts: 7
Finally I got the answer for this problem.

We need to pass the data base connection object to the hibernate session. That means both CMT and hibernate should use the same connection object.

we have a method in SessionFactory.OpenSession(Connection conn)

it will make use of the existing connection, here we no need to use any transaction object again.

-Kiran


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.