-->
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: Cache Identifier for INSERT
PostPosted: Mon Aug 16, 2004 1:22 pm 
Newbie

Joined: Mon Aug 16, 2004 12:37 pm
Posts: 2
Hibernate version: 2.1

Is there a way to cache Identifier for INSERT since SequenceGenerator requires two SQL queries to insert a new object.

Anybody has suggestions on how to use "sequence.nextVal". Will "sequence.nextVal" work if I am inserting graph of objects where objects are related by id's?

Alternate solution:
Although it is very easy to write custom CacheSequenceGenerator which extends net.sf.hibernate.id.SequenceGenerator but still sequence.nextval seems better solution.

Alternate solution:
Can use "before-insert" triggers but do not want to write lot of triggers.

Alternate solution:
Can't use Native-SQL.

I do not need returned identifier which hibernate returns when INSERT is executed.

Thanks
Manish Singla


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 16, 2004 6:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use the sequence hilo generator

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 5:22 pm 
Newbie

Joined: Mon Aug 16, 2004 12:37 pm
Posts: 2
Thanks...I tested "sequence hilo generator" and it solved my problem.

QUESTION

In hibernate documentaion following is written below seqhilo.
What does it means??

"Unfortunately, you can't use hilo when supplying your own Connection to Hibernate, or when Hibernate is using an application server datasource to obtain connections enlisted with JTA. Hibernate must be able to fetch the "hi" value in a new transaction."

http://www.hibernate.org/hib_docs/refer ... on-id-hilo

We are using application server datasource enlisted with JTA.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 3:36 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The problem is due to Tx, but a sequence is by design outside the Tx scope. So this warn does not apply to you.

_________________
Emmanuel


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.