-->
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: Dealing with MS SQLServer 2005 Money Data Type
PostPosted: Wed Sep 03, 2008 10:45 pm 
Newbie

Joined: Wed Sep 03, 2008 10:30 pm
Posts: 2
I am using Hibernate with JPA annotations on my POJO's and was until recently having trouble getting Hibernate to recognize the money type reported by MS SQLServer 2005:

@Column(name = "purchase_price", scale = 4)
@Type(type="big_decimal")
public BigDecimal getPurchasePrice() {
return this.purchasePrice;
}

The only way I could figure out how to do this was to extend the SQLServerDialect in order to support the type as follows:

/*
* Custom class extending SQLServerDialect to recognize money data type
*/
public class MyDialect extends SQLServerDialect {

public MyDialect() {
super();
registerColumnType( Types.NUMERIC, "money" );
}
}

and configure Hibernate to use it instead of SQLServerDialect. Is there a more elegant way to achieve the same result in either the Hibernate configuration or using JPA annotations on the attribute? If there is a way to do this using hbm.xml mappings, I would like to hear about it also.

Thanks for any help,
Bernard


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.