-->
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: unidirectional @oneToMany not working as expected
PostPosted: Sat Apr 15, 2006 7:46 am 
Newbie

Joined: Sat Mar 04, 2006 10:07 am
Posts: 9
Hi, has had a unexpecetd result from a simple mapping. Would expect that
when i create a new transient tournament and a new transient user and add the user to the tournaments participants list the user such be cascade createed with the tournament, when i in my dao call saveOrUpdate with the tournament?
Or such i call parsist in order for the CascadeType.Persist to work...?

Hibernate version: 3.1.3 , Annotations 3.1beta7

In tournament entity:

@OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
public Set<User> getParticipants() {
return participants;
}

My dao uses a saveOrUpdate()

org.hibernate.TransientObjectException: com.mycompany.model.user.User
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:697)
at org.hibernate.persister.collection.AbstractCollectionPersister.recreate(AbstractCollectionPersister.java:1037)
at org.hibernate.action.CollectionRecreateAction.execute(CollectionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:143)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)

Name and version of the database you are using: PostgreSql 8.1.3

_________________
Epllcr


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 9:13 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
if you're using Hiernate core (and not HEM), then yoyu need to cascade SAVE_UDAPTE

@org.hibernate.annotations.Cascade(SAVE_UPDATE)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 10:55 am 
Newbie

Joined: Sat Mar 04, 2006 10:07 am
Posts: 9
Thanks for the repley.

_________________
Epllcr


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.