-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to insert two tables in the DAO layer?
PostPosted: Wed Dec 15, 2004 10:24 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:

I want to insert two tables in one transaction . But I don't want to pass the transaction logic into DAO. And I also don't want to do this in my servlet. How to do it?[/url]

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 4:02 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what?
are you talking about insert table (insert into....) or persisting new instances? (session.save, session.create, or maybe dao.save)?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: :(
PostPosted: Thu Dec 16, 2004 6:55 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
anthony wrote:
what?
are you talking about insert table (insert into....) or persisting new instances? (session.save, session.create, or maybe dao.save)?


Hi anthony


I use JTA Transaction.
But it can't insert data using the following code:
Code:

UserTransaction utx=......................

doInsertItem(item1);
doUpdateItem(item2);

utx.commit().
.......................................


The two method is:
Code:
public void doInsertItem(Object item){

  Session s=HibernateUtil.currentSession();
  s.save(item);
  HibernateUtil.closeSession();
}

public void doUpdateItem(Object item){

  Session s=HibernateUtil.currentSession();
  item.set.....
. .......................
  s.update(item);
  HibernateUtil.closeSession();
}


This method can't insert and update database.Why? If I commit transaction in two method,it can't be in the same transaction. How to do it correctly?
Thks[/code]

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 7:14 am 
Newbie

Joined: Mon Aug 09, 2004 7:29 am
Posts: 10
Location: India
Take a look at this.
http://hibernate.org/42.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.