-->
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: how to deal with the property of custom type
PostPosted: Tue Dec 23, 2003 1:44 pm 
Beginner
Beginner

Joined: Fri Oct 24, 2003 10:45 am
Posts: 22
Hi all,

probably my question was answered before, but I could not find anything...

I have the following property mapping:

<property name="amount" column="amount" type="Currency"/>

Currency is my own class:

public class Currency {

public Currency(long dollars, long cents) {

if (dollars >= 0)
{
currencyCents = (dollars * 100) + Math.abs(cents);
}
else
{
currencyCents = (dollars * 100) - Math.abs(cents);
}

}

// various methods

protected long currencyCents;
}

I want the database table to store currencyCents field in "amount" column.

Is there any way to do it??

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2003 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Use a Custom type, have a look at the doc.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2003 2:34 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
A custom type is a class implementing UserType

_________________
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.