-->
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.  [ 2 posts ] 
Author Message
 Post subject: persisting annotations 1-1 example 2.2.5.1
PostPosted: Mon Dec 19, 2005 1:04 pm 
Newbie

Joined: Tue Nov 22, 2005 9:09 am
Posts: 4
Has anyone been able to get this example to persist using Hib 3.1 and annontations b7 ?

I get the exception below when tryint to save a body instance from the example with the following code

(using GeneratorType.AUTO for Body and GenerateType.NONE for Heart):

try {
Session s = HibernateUtil.currentSession();
s.beginTransaction();

Body b = new Body();
b.setHeart(new Heart());

s.saveOrUpdate(b);
s.getTransaction().commit();
} catch (Throwable t) {
t.printStackTrace();
}

create table body (
id bigint(18) unsigned not null auto_increment,
primary key(id)
);

create table heart (
id bigint(18) unsigned not null,
primary key(id)
);


Hibernate: insert into body values ( )
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): airtime.provisioning.Heart

at org.hibernate.id.Assigned.generate(Assigned.java:33)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingAction.java:134)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:410)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:299)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:520)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:513)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:509)
at airtime.provisioning.XTest.main(XTest.java:16)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 2:28 pm 
Newbie

Joined: Tue Nov 22, 2005 9:09 am
Posts: 4
Nevermind, found the reason why in the test case OneToOneTest.java.


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