About Question enthuware.oce-jpad.v6.1.438 :
Moderators: Site Manager, fjwalraven
About Question enthuware.oce-jpad.v6.1.438 :
An embeddable class may NOT be the key of a map annotated with @ElementCollection.
Can someone point me to the part of specification in 2.5 chapter that says something like this is true? I believe there are no constraints for embeddable class becoming a key in map
Can someone point me to the part of specification in 2.5 chapter that says something like this is true? I believe there are no constraints for embeddable class becoming a key in map
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.1.438 :
Hello,
This option is a wrong option. So yes, an embeddable class can be the key of a map. The explanation makes it even clearer, "When a map field is annotated with @OneToMany (or @ManyToMany), this means the map value is an Entity. The map key can be a basic type or an embeddable."
HTH,
Paul.
This option is a wrong option. So yes, an embeddable class can be the key of a map. The explanation makes it even clearer, "When a map field is annotated with @OneToMany (or @ManyToMany), this means the map value is an Entity. The map key can be a basic type or an embeddable."
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Tue Jan 10, 2012 12:18 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.1.438 :
Hello Paul,
I think Paul is asking the option 3 "An embeddable class may NOT be the key of a map annotated with @ElementCollection.". And you are explaining the option 2 "An embeddable class may NOT be the key of a map annotated with @OneToMany.".
I think both option 2 and 3 are not correct.
Thanks
I think Paul is asking the option 3 "An embeddable class may NOT be the key of a map annotated with @ElementCollection.". And you are explaining the option 2 "An embeddable class may NOT be the key of a map annotated with @OneToMany.".
I think both option 2 and 3 are not correct.
Thanks
-
- Posts: 17
- Joined: Sat Feb 28, 2015 2:26 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.1.438 :
Hello,
I guess map key can also be an Entity as well right ?"When a map field is annotated with @OneToMany (or @ManyToMany), this means the map value is an Entity. The map key can be a basic type or an embeddable."
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.1.438 :
No, if you have an entity as map key, then you are basically trying to create a relationship between 3 entities at the same time (because your map value is an entity as well). But the annotation @OneToMany is for relationship between two entities only.kotev_@abv.bg wrote:Hello,
I guess map key can also be an Entity as well right ?"When a map field is annotated with @OneToMany (or @ManyToMany), this means the map value is an Entity. The map key can be a basic type or an embeddable."
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 17
- Joined: Sat Feb 28, 2015 2:26 am
- Contact:
Re: About Question enthuware.oce-jpad.v6.1.438 :
Hi Paul,
Exactly. With Map you made relationship between three entities. To my understanding this is correct. I have the following mapping in Department entity:
@OneToMany(mappedBy = "department")
Map<Office, Employee> employees;
On Employee side:
@ManyToOne
Department department
As a result through department field I can queue employees map by office key.
In specification "2.7 Map Collections" is written that:
Exactly. With Map you made relationship between three entities. To my understanding this is correct. I have the following mapping in Department entity:
@OneToMany(mappedBy = "department")
Map<Office, Employee> employees;
On Employee side:
@ManyToOne
Department department
As a result through department field I can queue employees map by office key.
In specification "2.7 Map Collections" is written that:
9 possible map types are available and one of them is Map<Entity, Entity>.The map key and the map value independently can each be a basic type, an embeddable class, or an entity.
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-jpad.v6.1.438 :
Yes, you are right. I have updated the explanation. It still remains an incorrect option though.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 139 guests