-->
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.  [ 3 posts ] 
Author Message
 Post subject: Strange sequence behavior
PostPosted: Tue Dec 04, 2007 10:50 am 
Newbie

Joined: Tue Dec 04, 2007 10:11 am
Posts: 2
Location: Germany
Hibernate version: 3.2.0

Hello,

I've run into some strange problems with sequences. I am using Hibernate Annotations 3.2.0 with an Oracle 9i database. My class looks like this:

Code:
@Entity
@Table(name="PLANNING_ENTRY", schema="EDACPLANNING")
@SequenceGenerator(name="IDGEN",sequenceName="EDACPLANNING.SEQ_PLANNING_ENTRY")
public class PlanningEntry extends EdacObject
{
  ...

  @Id
  @Column(name="PE_ID")
  @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="IDGEN")
  public int getId()
  {
    return this.id;
  }


This works quite fine except that when saving such an object not the next number of the sequence, but approx. the next number multiplied with 50 is used. Is this a bug or a feature? I did not find anything about this neither in the docs nor in the forum.

Does anyone know this behvior? How can this problem be solved so that the numbers of the sequence will be used?

Regards,
Ralf.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 10:28 am 
Newbie

Joined: Tue Feb 19, 2008 9:35 am
Posts: 2
I can confirm this problem when using field annotations.

With the following Annotations Hibernate uses SequenceHiLoGenerator.
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "XXX")
@SequenceGenerator(name = "XXX", sequenceName = "XXX_ID_SE")
private long id;

2008-02-19 13:54:48,164 [main] DEBUG - select XXX_ID_SE.nextval from dual
2008-02-19 13:54:48,773 [main] DEBUG - Sequence identifier generated: 1748
2008-02-19 13:54:48,773 [main] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-02-19 13:54:48,774 [main] DEBUG - aggressively releasing JDBC connection
2008-02-19 13:54:48,774 [main] DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2008-02-19 13:54:48,774 [main] DEBUG - new hi value: 1748
2008-02-19 13:54:48,775 [main] DEBUG - generated identifier: 87400, using strategy: org.hibernate.id.SequenceHiLoGenerator

If you don't specify a generator Hibernate defaults to AUTO and uses SequenceGenerator
@Id
@GeneratedValue(generator = "XXX")
@SequenceGenerator(name = "XXX", sequenceName = "XXX_ID_SE")
private long id;

2008-02-19 13:58:59,188 [main] DEBUG - select XXX_ID_SE.nextval from dual
2008-02-19 13:58:59,801 [main] DEBUG - Sequence identifier generated: 1749
2008-02-19 13:58:59,801 [main] DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2008-02-19 13:58:59,802 [main] DEBUG - aggressively releasing JDBC connection
2008-02-19 13:58:59,802 [main] DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2008-02-19 13:58:59,802 [main] DEBUG - generated identifier: 1749, using strategy: org.hibernate.id.SequenceGenerator

Seems to be a bug in hibernate...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 19, 2008 10:48 am 
Newbie

Joined: Tue Feb 19, 2008 9:35 am
Posts: 2
http://opensource.atlassian.com/project ... se/ANN-354

/* no comment */


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