JPA: how to map map to date as key

Usually you match date as @Temporal(TemporalType.DATE)

, and you should display the card <> as @ManyToMany

or @Lob

.

Now I am trying to display a map. I tried @ManyToMany @Temporal(TemporalType.DATE)

it but it doesn't work:

Exception Description: The type [class java.util.Map] for the attribute [x] on the entity class [y] is not a valid type for a temporal mapping.

      

So my question is, how do I display a map that contains a date?

+2


source to share


1 answer


Have you tried something like this?



 @OneToMany
 @MapKeyTemporal(DATE)
 protected java.util.Map<java.util.Date, Employee> employees;

      

+3


source







All Articles