-->
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.  [ 7 posts ] 
Author Message
 Post subject: How to enforce EnumType.STRING on an EnumMap?
PostPosted: Mon Aug 27, 2007 1:21 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Hi,

normally I use something like this

Code:
@Enumerated(value=EnumType.STRING)


on a property, to enforce string mapping of the Enum.

But this doesn't seem to work on a EnumMap.

Any suggestions?

Thanks.

Greetings Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 3:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
what do you mean by enummap?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 4:32 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Hi,

with EnumMap I mean
java.util.EnumMap<K,V>
http://java.sun.com/javase/6/docs/api/j ... umMap.html

Which I can't declare diretly, cause Hibernate don't knows that. So I decalre it as e.g.:
Map<? extends Enum<?>, String>

and I wan't to ensure that the keys are mapped as Strings and not as int-values.

How can I annotate this?

By the way is it possible to change the default mapping of all Enum for all occurencies in any property, instead of using
Code:
@Enumerated(value=EnumType.STRING)
on all properties?

Thanks a lot.

Greetings Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 28, 2007 9:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Interesting, can you open a JIRA issue, we need to figure out a way to express that, but I don't see an elegent solution today.

As for changing the default enum type, no we cannot, that would go against the JPA spec.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 3:44 am 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Hi,

first of all thanks for your quick reply.
JIRA is filed:
http://opensource.atlassian.com/project ... se/ANN-657
Hope this is ok so.

My last question was unclear.

Quote:
By the way is it possible to change the default mapping of all Enum for all occurencies in any property, instead of using
@Enumerated(value=EnumType.STRING)
on all properties?


What I was looking for is an annotation
for the key word
Code:
enum


e.g.
Code:
public enum KnownCountries {

which changes the default behavior for this enum for every property where I used that enum as property.
Is this also against JPA?
At least it would be more convenient if you can change the default and only have to change it, on properties where you don't want your own default type.

Greetings Michael


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 5:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ah, that's interesting. can you post this idea to the JPA 2 expert group (can't remember the address though).

Also open a JIRA issue, an mark it with version: JPA 2 (there should be a version like that I think)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 9:25 am 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Hi,

I filed an subtask of my original JIRA.
http://opensource.atlassian.com/project ... se/ANN-658

I didn't find the JPA2 group either, but this isn't so important, cause it is just a convenience feature . Perhaps it will get there anyway through the JIRA.

Feel free to do so, if you want to submit this to the JPA2-Group.

Greetings Michael


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.