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 Guy,

Sorry for the late response.

Thanks for your help, it was really useful for me. Also I've figured out that I had to use the supertype Map instead of the subtype HashMap.

Best regards,

Rick

Op 15 dec. 2011 14:47 schreef "Guy Pelletier" <guy.pelletier@xxxxxxxxxx> het volgende:
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

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


Back to the top