-->
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: Sequence generator with annotations uses hilo instead of seq
PostPosted: Thu Jun 01, 2006 5:52 am 
Newbie

Joined: Thu Jun 01, 2006 5:43 am
Posts: 3
Hi,

I'm using hibernate annotations 3.2.0 CR1 with firebird database.

I want to use the sequence generator but it seems that hibernate uses the hilo generator internally.

My Class:

Code:
@Entity
@Table(name="MY_TEST")
@SequenceGenerator(name="PK",sequenceName="SQ_MY_TEST_ID")
public class MyTest {
   private Long id;

   @Id
   @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PK")
   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }
   @Column(name="BEZEICHNUNG",length=200, unique=true)
   private String bezeichnung;

   public String getBezeichnung() {
      return bezeichnung;
   }

   public void setBezeichnung(String bezeichnung) {
      this.bezeichnung = bezeichnung;
   }
}


And the debug logging information:

    11:34:17,944 DEBUG JDBCTransaction:54 - begin
    11:34:17,945 DEBUG ConnectionManager:415 - opening JDBC connection
    11:34:17,946 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
    11:34:17,951 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
    11:34:17,951 DEBUG JDBCTransaction:59 - current autocommit status: false
    11:34:17,952 DEBUG JDBCContext:203 - after transaction begin
    11:34:17,964 DEBUG AbstractSaveEventListener:489 - transient instance of: test.MyTest
    11:34:17,964 DEBUG DefaultSaveOrUpdateEventListener:161 - saving transient instance
    11:34:17,965 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    11:34:17,965 DEBUG SQL:393 - select gen_id( SQ_MY_TEST_ID, 1 ) from RDB$DATABASE
    11:34:17,966 DEBUG AbstractBatcher:476 - preparing statement
    11:34:17,969 DEBUG SequenceGenerator:82 - Sequence identifier generated: 7
    11:34:17,969 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    11:34:17,970 DEBUG AbstractBatcher:525 - closing statement
    11:34:17,971 DEBUG SequenceHiLoGenerator:62 - new hi value: 7
    11:34:17,971 DEBUG AbstractSaveEventListener:113 - generated identifier: 350, using strategy: org.hibernate.id.SequenceHiLoGenerator
    11:34:17,976 DEBUG AbstractSaveEventListener:152 - saving [test.MyTest#350]
    11:34:17,983 DEBUG JDBCTransaction:103 - commit
    11:34:17,984 DEBUG SessionImpl:339 - automatically flushing session
    11:34:17,984 DEBUG AbstractFlushingEventListener:58 - flushing session
    11:34:17,985 DEBUG AbstractFlushingEventListener:111 - processing flush-time cascades
    11:34:17,986 DEBUG AbstractFlushingEventListener:153 - dirty checking collections
    11:34:17,987 DEBUG AbstractFlushingEventListener:170 - Flushing entities and processing referenced collections
    11:34:17,989 DEBUG AbstractFlushingEventListener:209 - Processing unreferenced collections
    11:34:17,989 DEBUG AbstractFlushingEventListener:223 - Scheduling collection removes/(re)creates/updates
    11:34:17,990 DEBUG AbstractFlushingEventListener:85 - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
    11:34:17,990 DEBUG AbstractFlushingEventListener:91 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    11:34:17,991 DEBUG Printer:83 - listing entities:
    11:34:17,995 DEBUG Printer:90 - test.MyTest{bezeichnung=yuio, traversal=0, id=350}
    11:34:17,995 DEBUG AbstractFlushingEventListener:289 - executing flush
    11:34:17,995 DEBUG ConnectionManager:463 - registering flush begin
    11:34:17,996 DEBUG AbstractEntityPersister:2090 - Inserting entity: [test.MyTest#350]
    11:34:17,996 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    11:34:17,997 DEBUG SQL:393 - insert into MY_TEST (bezeichnung, traversal, id) values (?, ?, ?)
    11:34:17,997 DEBUG AbstractBatcher:476 - preparing statement
    11:34:17,999 DEBUG AbstractEntityPersister:1905 - Dehydrating entity: [test.MyTest#350]

Any hint's what I'm doing wrong?

Thanks a lot,

Chris[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 08, 2006 2:00 pm 
Newbie

Joined: Wed Jun 07, 2006 4:10 pm
Posts: 1
I came across this link that may help:

http://www.jboss.org/index.html?module= ... ic&t=84131


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 10:04 am 
Newbie

Joined: Thu Jun 01, 2006 5:43 am
Posts: 3
Hi,

thanks a lot - this one did it. Even if I don't understand why. I would understand it, if the default value alters the generator by 50 - but it doesn't alter it at all (firebird does not support generator caching).

Thanks,

Chris


Top
 Profile  
 
 Post subject: Re: Sequence generator with annotations uses hilo instead of seq
PostPosted: Thu Nov 22, 2012 2:07 pm 
Newbie

Joined: Thu Nov 22, 2012 1:59 pm
Posts: 1
insted of 'GenerationType.SEQUENCE', use 'GenerationType.AUTO' , it will not give caching problem.

e.g.
@Id
@SequenceGenerator(name = "studentId", sequenceName = "student_Id")
@GeneratedValue(strategy = GenerationType.AUTO, generator="studentId")
private int studentId;


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.