-->
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.  [ 1 post ] 
Author Message
 Post subject: In need of a Mutable user type example
PostPosted: Thu Sep 30, 2004 5:52 am 
Newbie

Joined: Thu Sep 30, 2004 5:02 am
Posts: 12
Location: Belgium
I have been looking a while, but a cannot seem to find any example of a mutable (composite)(user) type, i.e., a type with isMutable() == true.

In particular, I am anxious to find out whether, with such a type, Hibernate can be coerced on object load not to create a new instance of the mutable type for a particular object property, but to change the existing instance of the mutable type that is the property value.

E.g.

Code:
public class MyClass {

  public final java.util.Date importantDate = new java.util.Date();

}


The MyClass. importantDate property is never null, but it is final. Since Date is mutable, Hibernate could, on load, call MyClass.importantDate.setTime(long), instead of creating a new Date instance and try to set the MyClass.importantDate property with the new instance.
Obviously, there is some kind of type class needed to tell Hibernate that it should use the setTime(long) (and getTime()) method to write and read the property. Or is it simply possible to use a hbm entry that features a path in the property name? Like:
Code:
     <property name="importantDate.time"
               type="java.util.Date"
               update="true"
               insert="true"
               access="property"
               column="importantDate" />


But then still, it would be usefull to have a place where we can state once and for all that, if a property is of type java.util.Date, Hibernate should change the existing object instead of creating a new one.

(Don't focus on the java.util.Date - it is just the mutable type closest at hand).

_________________
+- no sig for religous reasons -+


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.