So this is another representation of a choice we are having to make quite a
bit in 5.0 development... correctness versus "legacy", which has really
implications for users. So if users are relying on this Hibernate
"feature" of splitting identifier mapping annotations between the entity
and the IdClass, their apps would break if we now start supporting this
"the correct way".
Maybe this is another case where we can log warning for "misplaced"
annotations when we see an IdClass with persistence mapping annotations.
The spec makes no mention of use cases where an IdClass has mapping
annotations, nor do I consider this a "usability feature" from the users
perspective (aside from the mentioned compatibility concerns).
FWIW, I took these tests and changed the mappings to instead use @Id
@ManyToOne on the entity itself. Metamodel understood that perfectly
well...
On Thu, Mar 27, 2014 at 8:58 AM, Emmanuel Bernard <emmanuel(a)hibernate.org>wrote:
This code is 8 years old so no I did not remember.
I did some archeology. The Git migration slots all of that history so I
had to fire up svn.
svn checkout
https://svn.jboss.org/repos/hibernate/annotations/branches/v3_4_0_GA_CP/
svn annotate
src/test/java/org/hibernate/test/annotations/cid/OrderLinePk.java
svn log -r 11058
src/test/java/org/hibernate/test/annotations/cid/OrderLinePk.java
svn log | grep -C 3 ANN-492
Anyways, it is related to the following:
https://hibernate.atlassian.net/browse/HHH-4259
https://hibernate.atlassian.net/browse/ANN-492
https://forum.hibernate.org/viewtopic.php?t=967202&start=0&postda...
It looks like a combination of the following:
- the old code was not able to get the annotation metadata from the
entity. It was getting the metadata from the id class. Against the
spec but it was a tough bug to fix
- Goeffrey had a problem and contributed the test
- the test passed a future version of annotations when I applied it
- I left it here as coverage
On Thu 2014-03-27 11:59, Hardy Ferentschik wrote:
> No idea. I think Emmanuel had a better understanding of the derived
identifier logic.
>
>
>
> On 27 Jan 2014, at 06:26, Steve Ebersole <steve(a)hibernate.org> wrote:
>
> > What's the rational for supporting the following?
> >
> >
> > @Entity
> > class Product {
> > ...
> > }
> >
> > @Entity
> > class Order {
> > ...
> > }
> >
> > @Entity
> > @IdClass(...)
> > class OrderLine {
> > @Id
> > private Order order;
> >
> > @Id
> > private Product product;
> > }
> >
> > Specifically, the declaration of the OrderLine primary key. Why would
> > these not have to be `@Id @ManyToOne`?
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev(a)lists.jboss.org
> >
https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/hibernate-dev