-->
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: Component object is null when all its properties are null
PostPosted: Wed Nov 30, 2005 5:32 am 
Newbie

Joined: Wed Nov 30, 2005 5:18 am
Posts: 3
Hibernate version:3.0
Name and version of the database: HSQLDB, Firebird

Here is a part of the mapping:
<joined-subclass name="filters.AgeFilter">
<key column="ID"/>
<component name="interval" access="field">
<property name="minValue" access="field"/>
<property name="maxValue" access="field"/>
</component>
</joined-subclass>


If both minValue and maxValue are NULL then hibernate sets interval to NULL.
How this can be avoided . I have real case where all properties may be null but the component class must be instantiated. Even if I cteate it on the empty constructor Hibernate later sets it to null.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 8:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, this is explciitly covered in the docs.

For the behavior you suggest, use a custom type.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 12:17 pm 
Newbie

Joined: Wed Nov 30, 2005 5:18 am
Posts: 3
Well my class is

Interval<T extends Comparable>
T minValue;
T maxValue;
....

making a custom type for every kind of instances (Integer, Long, Date, etc) is not very nice solution. I have a temporary hack do deal with the problem - it is not a stopper for me. Can you tell me why Hibernate does not to make instance of the component object when all properties are null, or direct me to some docs where I can read about it. And why there is no setting to change this behaviour.

thank you


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.