Announcement Announcement Module
Collapse
No announcement yet.
Generate DAO for base class of inheritance hierarchy with Spring Data JPA Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Generate DAO for base class of inheritance hierarchy with Spring Data JPA

    I'm trying to generate the DAO for the following:
    Code:
    @MappedSuperclass
    @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
    public abstract class Shape implements IEntity {
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Column(name = "POLYGON_ID")
        private Long id;
    
        ...
    }
    This is the base class for classes such as:
    Code:
    @Entity
    @XmlRootElement(name = "circle")
    public class Circle extends Shape { ... }
    I am getting:
    Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.geogrep.persistence.entity.Shape
    at org.hibernate.ejb.metamodel.MetamodelImpl.managedT ype(MetamodelImpl.java:190) ~[hibernate-entitymanager-4.1.4.Final.jar:4.1.4.Final]
    at org.springframework.data.jpa.repository.support.Jp aMetamodelEntityInformation.<init>(JpaMetamodelEnt ityInformation.java:58) ~[spring-data-jpa-1.1.0.RELEASE.jar:na]

    Which makes some sense - but I am wondering - is there another way to map these so that Spring Data (with the help of the Hibernate Metamodel Generator) is able to generate the DAO for the base class? I'm thinking that a usecase where you have a base class and a child class, and DAOs for both is relatively common.
    I am using Hibernate 4.1.4 and Spring Data JPA 1.1.0.
    Thanks.
    Eugen.
Working...
X