Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] How to annotate a HashMap which uses a selfmade type as key?

Hi Rick,

You can use an @ElementCollection to map this.

http://docs.oracle.com/html/E26376_01/javax/persistence/ElementCollection.html

Example:
http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Example_of_a_map_key_class_embedded_relationship_annotation

Cheers,
Guy

On 15/12/2011 8:12 AM, Rick van Son wrote:
Hello everyone,

How can i annotate a Java HashMap, which uses a selfmade type as key?

I tried several things i've found on the internet, but EclipseLink doesn't like them or they appear to be hopelessly outdated.

It's a bit like this:

private HashMap<TimeSpan, String> normalWorkingTimes;

Please note that the class TimeSpan is annotated as @Embeddable, so it doesn't have a table on it's own.

Thanks in advance,

Rick
_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top