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: How to map an immutable class/fields?
PostPosted: Tue Dec 12, 2006 11:16 am 
Beginner
Beginner

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

Can anyone suggest whether it is possible to map the following class?
The problem is that I should have a default constructor (plus setters), which conflicts with java final keyword.

If you could point me to the relevant part in the doc, I would appreciate.

Thank you.

Code:
public class Question {
   
    private final String name;
    private final String value;

    public Question(String name, String value) {
        this.name = name;
        this.value = value;
    }
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 11:52 am 
Newbie

Joined: Wed Dec 06, 2006 6:30 pm
Posts: 8
I think you would want to implement a UserType and store each field as a Hibernate.STRING. Check out documentation on custom value types:

http://www.hibernate.org/hib_docs/v3/re ... pes-custom

Creating your own user type is relatively easy with Hibernate. :)

-David


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.