[jboss-user] [EJB 3.0] - Problem using SequenceGenerator

bryan_castillo do-not-reply at jboss.com
Wed Jul 26 19:50:25 EDT 2006


I'm not sure whats going on here.  I'm trying to create an Entity bean for a pre-existing table in DB2 that uses a sequence for creating a new primary key.

Here is my annotated getter method.

	@Id
  | 	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="VNDR_ID_SEQ")
  | 	@SequenceGenerator(name="VNDR_ID_SEQ", sequenceName="VRAP.VNDR_ID_SEQ")
  | 	@Column(name="VNDR_ID")
  | 	public int getId() {
  | 		return id;
  | 	}


When I try to insert a new object, I see in the logs that it gets a value from
the sequence using the right sql with a value of 556.

anonymous wrote : 2006-07-26 16:35:02,819 INFO  [STDOUT] Hibernate: values nextval for VRAP.VNDR_ID_SEQ
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.id.SequenceGenerator] Sequence identifier generated: 556

Later in the logs it prints the values of the fields before inserting the object, and the id field has a value of 27800.


anonymous wrote : 2006-07-26 16:35:02,899 DEBUG [org.hibernate.pretty.Printer] bcc.entity.Vendor{createUserId=IS94901, updateTime=null, createTime=16:35:02, ndc5Nb=5150, createDate=26 July 2006, updateUserId=IS94901, updateDate=null, name=BryanV, id=27800, subsidiaryOf=Castillo Corp.}


Did I set up my annotations wrong?  I expected to have the id set to 556.



anonymous wrote : Snippet from logs:
  | ------------------------------------------
  | 
  | 
  | 
  | 2006-07-26 16:35:02,819 INFO  [STDOUT] Hibernate: values nextval for VRAP.VNDR_ID_SEQ
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.id.SequenceGenerator] Sequence identifier generated: 556
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.id.SequenceHiLoGenerator] new hi value: 556
  | 2006-07-26 16:35:02,869 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 27800, using strategy: org.hibernate.id.SequenceHiLoGenerator
  | 2006-07-26 16:35:02,889 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
  | 2006-07-26 16:35:02,899 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
  | 2006-07-26 16:35:02,899 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
  | 2006-07-26 16:35:02,899 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
  | 2006-07-26 16:35:02,899 DEBUG [org.hibernate.pretty.Printer] listing entities:
  | 2006-07-26 16:35:02,899 DEBUG [org.hibernate.pretty.Printer] bcc.entity.Vendor{createUserId=IS94901, updateTime=null, createTime=16:35:02, ndc5Nb=5150, createDate=26 July 2006, updateUserId=IS94901, updateDate=null, name=BryanV, id=27800, subsidiaryOf=Castillo Corp.}
  | 
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961159#3961159

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961159



More information about the jboss-user mailing list