-->
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 map User Type for element
PostPosted: Tue Jun 20, 2006 11:12 am 
Newbie

Joined: Tue Apr 19, 2005 10:15 am
Posts: 8
Hibernate version:
3.0
Name and version of the database you are using:
MySQL 4.1

Hi,
I had a simple class which had one User Type named state. Here is a mapping file fragment:
Code:
private State state;

...... getter/setter .........

<property name="state" column="STATE">
       <type name="jyaga.datawork.valuelabel.ValueLabelUserType">
                <param name="class">jyaga.datawork.type.State</param>
       </type>
</property>

Now I need to have List of States in this class instead of one state:
Code:
private List<State> states;

......... getter/setter .........

If it would be just String (List<String>) it would be simple:
Code:
<bag name="states" table="good_faith_estimate_state">
            <key column="CORR_ID"/>
            <element column="STATE" type="string"/>
</bag>

But how to map User Type with parameter in this case?
Please help,
thanks,
Eugene


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 11:26 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Easiest thing to do is to add a typedef near the beginning of your .hbm.xml file. See ref docs, section 5.2. You'll have something like:
Code:
<typedef class="jyaga.datawork.valuelabel.ValueLabelUserType"  name="state">
    <param name="class">jyaga.datawork.type.State</param>
</typedef>
Then anywhere you need to use that user type, including in the bag, you can use type="state".

_________________
Code tags are your friend. Know them and use them.


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