Github has been down for a while, so moving to mailing list.
Hi @pdinc-oss ,
the issue it is how you define the `IdClass`
for such a case
```
@Entity
@IdClass(PK.class)
public static class NodeS {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long nid;
@Id
@ManyToOne
private HeadS hid;
...
}
```
the class has to be
```
class PK implements Serializable {
private Long nid;
private HeadS hid;
public PK(Long nid, HeadS hid) {
this.nid = nid;
this.hid = hid;
}
...
}
```
JPA 2 spec 2.4.1.3 Examples of Derived Identities,
Case (a): The dependent entity uses IdClass to represent a composite key:
```
public class DependentId {
String name; // matches name of @Id attribute
long emp; // matches name of @Id attribute and type of Employee PK
}
@Entity
@IdClass(DependentId.class)
public class Dependent {
@Id String name;
// id attribute mapped by join column default
@Id @ManyToOne Employee emp;
...
}
```
HeadS is the Entity type and its Id type is Long.
I backed out the changes to SimpleValue.java/AbstractEntityTuplizer.java and changed the
IdClasses to match and it does pass the tests in Hibernate.
But when testing 2.4.1.3, case a without the patch the following tests fails:
- testCompositePkWithIdentityAndFKByAuto: No part of a composite identifier may be null
- testCompositePkWithIdentityAndFKByAuto2: No part of a composite identifier may be null
- testCompositePkWithIdentityAndFKBySequence: No part of a composite identifier may be
null
- testCompositePkWithIdentityAndFKBySequence2: No part of a composite identifier may be
null
- testCompositePkWithIdentityAndFKByTable: No part of a composite identifier may be null
- testCompositePkWithIdentityAndFKByTable2: No part of a composite identifier may be null
These tests are expected to fail / ignored:
- testCompositePkWithIdentityAndFKByIdentity: No part of a composite identifier may be
null
- testCompositePkWithIdentityAndFKByIdentity2: skipped
-Jason
—
You are receiving this because you were mentioned.
Reply to this email directly,
https://github.com/hibernate/hibernate-orm/pull/3368#issuecomment-618352419, or
https://github.com/notifications/unsubscribe-auth/AAQUDIQWBZ5E4INWC5ELIZ3....