org.hibernate.AnnotationException: Cannot mix @javax.persistence.MakKey and @org.hibernate.annotations.MapKey on the same collection: SingleClassTestCase$Parent.children

Hibernate JIRA | Heiko Briebrecher | 1 decade ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Mapping Collections as Maps with @javax.persistence.MapKey does not work in Beta 10 (Beta 9 was fine). @org.hibernate.annotations.MapKey is not used anywhere in the code. Plus there's a typo ("MakKey ") in the Exception Message. -- snip -- Exception: org.hibernate.AnnotationException: Cannot mix @javax.persistence.MakKey and @org.hibernate.annotations.MapKey on the same collection: SingleClassTestCase$Parent.children at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:258) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1367) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:650) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:326) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:238) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172) -- snip -- Entities: /** * Person */ @MappedSuperclass private static abstract class Person implements Serializable { @Id @GeneratedValue Integer id; @Version @Column(nullable = false) Integer version; public static final String NAME = "name"; @Column(nullable = false) String name; } /** * Parent */ @Entity @Table(name = "PARENT") private static class Parent extends Person { @OneToMany(mappedBy=Child.PARENT) @Cascade(value = {org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) @MapKey(name=Child.NAME) Map<String, Child> children = new HashMap<String, Child>(); } /** * Child */ @Entity @Table(name = "CHILD") private static class Child extends Person { private static final String FK_PARENT = "parent_id"; static final String PARENT = "parent"; @ManyToOne(optional = false) @JoinColumn(name = FK_PARENT, nullable = false) Parent parent; }

    Hibernate JIRA | 1 decade ago | Heiko Briebrecher
    org.hibernate.AnnotationException: Cannot mix @javax.persistence.MakKey and @org.hibernate.annotations.MapKey on the same collection: SingleClassTestCase$Parent.children
  2. 0

    Mapping Collections as Maps with @javax.persistence.MapKey does not work in Beta 10 (Beta 9 was fine). @org.hibernate.annotations.MapKey is not used anywhere in the code. Plus there's a typo ("MakKey ") in the Exception Message. -- snip -- Exception: org.hibernate.AnnotationException: Cannot mix @javax.persistence.MakKey and @org.hibernate.annotations.MapKey on the same collection: SingleClassTestCase$Parent.children at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:258) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1367) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:650) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:326) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:238) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172) -- snip -- Entities: /** * Person */ @MappedSuperclass private static abstract class Person implements Serializable { @Id @GeneratedValue Integer id; @Version @Column(nullable = false) Integer version; public static final String NAME = "name"; @Column(nullable = false) String name; } /** * Parent */ @Entity @Table(name = "PARENT") private static class Parent extends Person { @OneToMany(mappedBy=Child.PARENT) @Cascade(value = {org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN }) @MapKey(name=Child.NAME) Map<String, Child> children = new HashMap<String, Child>(); } /** * Child */ @Entity @Table(name = "CHILD") private static class Child extends Person { private static final String FK_PARENT = "parent_id"; static final String PARENT = "parent"; @ManyToOne(optional = false) @JoinColumn(name = FK_PARENT, nullable = false) Parent parent; }

    Hibernate JIRA | 1 decade ago | Heiko Briebrecher
    org.hibernate.AnnotationException: Cannot mix @javax.persistence.MakKey and @org.hibernate.annotations.MapKey on the same collection: SingleClassTestCase$Parent.children
  3. 0

    Spring Boot JTA Error

    Stack Overflow | 2 years ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    hibernate error when using single table inheritance

    Stack Overflow | 2 years ago | P.Péter
    org.hibernate.AnnotationException: Foreign key circularity dependency involving the following tables:
  6. 0

    query regarding one to many relationship in hibernate

    Stack Overflow | 2 years ago | arjun narahari
    org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: com.hibernate.arjun3.Author.book

  1. batwalrus76 3 times, last 3 weeks ago
  2. davidvanlaatum 2 times, last 4 months ago
  3. r1chjames 1 times, last 8 months ago
  4. Kawada 108 times, last 10 months ago
  5. tjago 4 times, last 10 months ago
43 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.hibernate.AnnotationException

    Cannot mix @javax.persistence.MakKey and @org.hibernate.annotations.MapKey on the same collection: SingleClassTestCase$Parent.children

    at org.hibernate.cfg.annotations.CollectionBinder.bind()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:258)
    2. org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1367)
    3. org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:650)
    4. org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:326)
    5. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:238)
    6. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172)
    6 frames