-->
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: Question on creating custom type
PostPosted: Fri Jul 18, 2008 12:29 am 
Newbie

Joined: Tue Oct 02, 2007 3:49 am
Posts: 17
Hi All,

I manage to create a custom type for money. It contains currency and amount. I read some topics from Internet. I found there's annotation @Embedded and @org.hibernate.annotation.Type. It seems both of them doing the same thing. My questions is what diff. between these two and also which one is the best to do in my situation? Can anyone give me some advice.

Best Rdgs
Ellis


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 4:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

there is a conceptional difference. @Embedded is about the component concept. It allows you to have the properties of an @Embeddable class mapped into the table of the entity using the embeddable class. In Hibernate calls @Embeddable classes components - http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#components-dependentobjects. Components express to a certain degree what in UML is considered an aggregation.

On the other hand you can tell Hibernate how to persist a certain poperty/class by defining a custom type - http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#mapping-types-custom.

Of course you could also map your money class as full entity.

Which way you choose depends to a certain degree on your personal taste and requirements. I would probably use the component or full entity approach.

--Hardy


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.