Search code examples
hibernatejpacomposite-primary-keycomposite-id

Composite Key in JPA / Hibernate with inherited class


i have a composite id defined on my class structure as below. Unfortunatly i always get a hibernate error that complains on the not found "part2":

"Property of @IdClass not found in entity MoreClass : part2"

Can anybody help me on fixing the problem? (or at least point me on a helpful jpa/hibernate doc?)

@IdClass(ClassKey.class)
@Entity
public class MoreClass extends LessClass implements Serializable
{
  @Id
  String part1;
}

@MappedSuperclass
public class LessClass implements Serializable
{
   @Id
   String part2;
}

public class ClassKey implements Serializable
{
   String part1;
   String part2;
}

Solution

  • Actually bumped into the same problem.

    As:

    @Override
    @Id
    public getPart2() {
       return super.getPart2();
    }
    

    Does seem to work, I would deem it a bug. See https://hibernate.atlassian.net/browse/HHH-9114.