-->
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: How to set value to UserType property in my entity
PostPosted: Mon Dec 27, 2004 1:29 am 
Beginner
Beginner

Joined: Sat Jan 31, 2004 10:09 am
Posts: 26
Hibernate version: 2.1.7

I read Hibernate in Action, it introduced us a new way to implement safe enumeration. but I still can't understand how to implement the logic to set value to my UserType entity.

for exemple,
A enumeration,
Code:
public class MyType implements Serializable {
   ...
}


A UserType implementation,
Code:
public class MyUserType implements UserType {
   ...
   public Class returnedClass() { return MyType.class; };
   ...
}


A Entity,
Code:
public class MyEntity {
   ...
   private Long id;
   private MyUserType myUserType;
   ...
}


As the example, how do I set the value to myUserType property in MyEntity?
What I means is that MyUserType is not an enumeration, how do I reflect the value user wanted to myUserType?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 27, 2004 5:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
public class MyEntity {
   ...
   private Long id;
   private MyType myType;
   ...
}

<class name="MyEntity"...>
  <property name="myType" type="full.package.MyUserType"/>
...
</class>

Check the doc for more informations

_________________
Emmanuel


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.