-->
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: Why do you need to initialize @Embedded objects?
PostPosted: Mon Jan 29, 2007 4:37 pm 
Newbie

Joined: Mon Nov 03, 2003 1:07 am
Posts: 14
I am using hibernate annotations with @Embedded objects. Things work fine if I do a Hibernate.initialize(my.getEmbeddedObject()) ,but if I don't do an explicit initilize on my embedded object, I get a
org.hibernate.PropertyValueException
not-null property references a null or transient value: com.reffects.dmi.dbom.PlaylistAttraction.nameDescription.name

Is there a way I can annotate the class so that this Embedded property is eagerly loaded when the class is loaded?

Thanks very much. I guess for now I am going to nuke my Embedded objects and just switch back to simple properties for now, but was wondering why this functions this way.



Hibernate version:
hibernate-3.2.0.cr1.jar
hibernate-annotations-3.1beta9.jar

Mapping documents:
@Embedded
public NameDescription getNameDescription() {
return nameDescription;
}
public void setNameDescription(NameDescription nameDescription) {
this.nameDescription = nameDescription;
}
private NameDescription nameDescription = new NameDescription();

Code between sessionFactory.openSession() and session.close():
//spring...

Full stack trace of any exception that occurs:
org.springframework.orm.hibernate3.HibernateSystemException
not-null property references a null or transient value: com.reffects.dmi.dbom.PlaylistAttraction.nameDescription.name; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.reffects.dmi.dbom.PlaylistAttraction.nameDescription.name


Top
 Profile  
 
 Post subject: Figured it out, bug
PostPosted: Wed Jan 31, 2007 11:52 am 
Newbie

Joined: Mon Nov 03, 2003 1:07 am
Posts: 14
this is kind of related to http://jira.jboss.com/jira/browse/HIBERNATE-50

I added a simple property to my EmbeddedObject, now everything is fine.


Summary:
If you use any EmbeddedObjects, include at least one simple property (int, boolean), if you have only string properties, you will have to explicitely initialize the object.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 5:41 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
it s not related to String, it's related to the fact that an object having null properties is set to null.

_________________
Emmanuel


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.