-->
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: Simple Custom Property Issues
PostPosted: Fri Oct 03, 2003 10:28 am 
Newbie

Joined: Wed Aug 27, 2003 5:21 pm
Posts: 7
Hi All,

I am having some issues getting a simple custom property to work. The setup is that I've got a SQL Server table where I want to store a double in a column, and I want my Hibernate object to contain a custom class (called Decimal, my own Number subclass), which will get populated via Hibernate when reading/writing to this table.

My HBM descriptor has the column as follows:

Code:
    <property name="myDecimal" type="some.package.Decimal">
      <column name="my_decimal" sql-type="double precision"/>
    </property>

I am able to create the table fine via SchemaExport, but Hibernate is giving me class cast exceptions when I try to load anything from this table. Does my Decimal class have to extend net.sf.hibernate.type.DoubleType? My Decimal object already extends Number, so I can't really do that, but are there other options here that I am missing and can explore?

Thanks in advance,
Adam


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2003 11:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
From the docs: To implement a custom type, implement either net.sf.hibernate.UserType or net.sf.hibernate.CompositeUserType and declare properties using the fully qualified classname of the type. Check out net.sf.hibernate.test.DoubleStringType to see the kind of things that are possible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2003 12:19 pm 
Newbie

Joined: Wed Aug 27, 2003 5:21 pm
Posts: 7
david wrote:
From the docs: To implement a custom type, implement either net.sf.hibernate.UserType or net.sf.hibernate.CompositeUserType and declare properties using the fully qualified classname of the type. Check out net.sf.hibernate.test.DoubleStringType to see the kind of things that are possible.

Thanks David. I actually figured out how to do this shortly after posting. I guess what I was looking for was a single-field example, and I found one in another posting that guided me in the right direction.

Adam


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.