-->
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: mapping Java 5 enum with additional fields
PostPosted: Wed Nov 29, 2006 8:14 am 
Beginner
Beginner

Joined: Fri Jun 09, 2006 4:21 pm
Posts: 23
Location: Reading
Hi everybody,

I need to map Java 5 enum, which contains additional fields, e.g.

Code:
public enum Transaction {
    TransactionAB("A", "B"),
    TransactionBA("B", "A");

    private String from;
    private String to;

    Transaction(String from, String to) {
        this.from = from;
        this.to = to;
    }
}


So far, for mapping simple enums I've been using GenericEnumUserType, but now how do I specify those additional fields which are part of enum?

Thanks for your help.


Last edited by vanyatka on Wed Nov 29, 2006 9:04 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 8:59 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
I think this tread can help you:

http://forum.hibernate.org/viewtopic.ph ... highlight=

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 11:00 am 
Beginner
Beginner

Joined: Fri Jun 09, 2006 4:21 pm
Posts: 23
Location: Reading
andresgr wrote:


Thanks andresgr, I'll have a look at it.

But can anyone tell me if I should use Java 5 enums, at all? I mean, Hibernate in Action (which is now is relatively "old") mentions java 5 enums and suggests NOT TO use them till they are introduced natively in Hibernate. As I can see now, all existing solutions for mapping enums are random posts from community and none of them officially approved (correct me if I'm wrong here). It's just a bit dubious to "copy-past" someone else's classes posted online and then rely on them, especially when something is wrong in the beginning and you look through your setup over and over, thinking "is it me or that 3rdparty implementation"? Does anyone know when native support of java 5 enum will be introduced?


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.