[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-657?page=co...
]
Michael Grünewald commented on ANN-657:
---------------------------------------
Hi,
a little bit more flexible way, would be to define an method which is accessed before the
mapping and only the result is mapped.
E.g. for enums the method would be "name" (public final String name()) or
"ordinal" (public final int ordinal())
So an @MapKey (action=name) would cause that name is called on every key and mapped as
String.
This would be also usefull if the key is an class which should not be mapped to the db.
So "hashcode" or toString could be another example for an usage of that.
I'm not quite sure if there any other useful situations out there, but at least it
would be very flexible and powerful. On the other hand the "enumerated" would be
more straight forward.
Greetings Michael
By the way, same should be aplied to @MapKeyManyToMany.
@Enumerated(value=EnumType.STRING) for Maps (java.util.EnumMap) ?
-----------------------------------------------------------------
Key: ANN-657
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-657
Project: Hibernate Annotations
Issue Type: Improvement
Affects Versions: 3.3.0.ga
Environment: hibernate 3.2.4.sp1; PostgresSql 8.2
Reporter: Michael Grünewald
Priority: Minor
Hi,
I faced the problem, that I can't enforce a String-Mapping for an enum type key of an
Map.
E.g.:
Map<? extends Enum<?>, String>
I would suppose to use an attribute for @MapKey to do that.
E.g.: @MapKey (enumerated=EnumType.STRING)
Please read the forum entry for more informations.
http://forum.hibernate.org/viewtopic.php?t=97827
Greetings Michael
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira