-->
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.  [ 9 posts ] 
Author Message
 Post subject: IdentifierGenerationException!
PostPosted: Fri Jun 30, 2006 10:11 am 
Newbie

Joined: Fri Apr 07, 2006 3:43 pm
Posts: 14
Guys,
I am getting org.hibernate.id.IdentifierGenerationException:ids for this class must be manually assigned before calling save():
at org.hibernate.id.Assigned.generate(Assigned.java:32)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)


Any inputs??


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 10:13 am 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
You did not mention what you are trying to do. There is little to be said without that.

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 10:48 am 
Newbie

Joined: Fri Apr 07, 2006 3:43 pm
Posts: 14
I am trying to save the data in my schema


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 1:43 pm 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
can you provide some of the mapping and the code where you actually call Session.save()?

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject: here you go!
PostPosted: Fri Jun 30, 2006 3:39 pm 
Newbie

Joined: Fri Apr 07, 2006 3:43 pm
Posts: 14
localSession.saveOrUpdate(vehicleData);

Mapping File:
<hibernate-mapping>
<class name="com.EB.VEHICLETYPE" table="VEHICLE_TYPE" >
<id name="vehicleName" type="java.lang.String">
<column name="VEHICLE_NAME" length="60" />

</id>
<property name="vehicleType" type="java.lang.String">
<column name="VEHICLE_TYPE" length="105" />
</property>
<property name="vehicleDetails" type="java.lang.String">
<column name="VEHICLE_DETAILS length="90" not-null="true" />
</property>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Need Help Guys with the following Exception!
PostPosted: Mon Jul 03, 2006 10:25 am 
Newbie

Joined: Fri Apr 07, 2006 3:43 pm
Posts: 14
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.vehicle.VehicleType
at org.hibernate.id.Assigned.generate(Assigned.java:32)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 05, 2006 4:54 pm 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
[quote]com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'tst_main' when IDENTITY_INSERT is set to OFF.
Code:
<id name="vehicleName" type="java.lang.String">
    <column name="VEHICLE_NAME" length="60" />
</id>

The class' identifier has no generator, so you have to assign one before saving. Did you check that property "vehicleName" does not return null right before Session.save()?
Note that once you assign the vehicleName and save the instance you will not be able to change that property.

_________________
Henrique Sousa
Don't forget to rate useful responses


Top
 Profile  
 
 Post subject: HibernateException!
PostPosted: Thu Jul 06, 2006 9:50 am 
Newbie

Joined: Fri Apr 07, 2006 3:43 pm
Posts: 14
Guys,

Need help with the following exception:
19328 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.HibernateException: Unexpected row count: 0 expected: 1
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:32)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1982)
at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1909)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2149)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.ihg.croservice.eis.db.HotelFactory.setBrand(HotelFactory.java:593)
at com.ihg.croservice.bo.EventManager.testSetBrand(EventManager.java:486)
at com.ihg.croservice.bo.EventManager.main(EventManager.java:129)
org.hibernate.HibernateException: Unexpected row count: 0 expected: 1
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:32)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1982)
at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1909)
at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2149)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 3:29 pm 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
Set hibernate property "show_sql" to true. A lot of SQL will be output to the console, and there should be an SQL query (an update?) right before that exception. If that is an update query make sure you did not change vehicleName (as I mentioned previously). If you did, and if this must be possible, you will have to change the primary key to an auto-generated value. Otherwise... actually, I am not sure what else could cause this.

_________________
Henrique Sousa
Don't forget to rate useful responses


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