hibernate - Spring data jpa inheritance - table per class not working -


i have abstract entity.

@entity @inheritance(strategy=inheritancetype.table_per_class) @entitylisteners(auditingentitylistener.class) public abstract class abstractentity {      @id     @generatedvalue(strategy = generationtype.auto)     protected long id;      @createdby     protected string createdby;      @createddate     protected date creationdate;      @lastmodifiedby     protected string modifiedby;      @lastmodifieddate     protected date lastmodifieddate;  } 

and 2 concrete implementations of class:

class a:

@entity @table(name = "a") public class extends abstractentity {      @column(name = "name", nullable = false)     private string name;      @column(name = "priority", nullable = false)     private int priority; } 

class b:

@entity @table(name = "b") public class b extends abstractentity {      @column(name = "place", nullable = false)     private string place;      @column(name = "distance", nullable = false)     private int distance; } 

and common repository interface:

@norepositorybean public interface irepository extends repository<abstractentity, long> {     /**      * method query unique id/pk.      * @param id      * @return entity id "id"      */     @query("select entity #{#entityname} entity entity.id = ?1")     public abstractentity findbyid(long id);      /**      * insert method      * @param abstractentity      * @return modified entity after insertion      */     public abstractentity save(abstractentity abstractentity);      /**      * select records table      * @return list of entities representing records in table      */     @query("select entity #{#entityname} entity")     public list<abstractentity> findall();      /**      * delete record id      * @param id      */     public void deletebyid(long id); } 

and each class has it's own repository extends generic repository:

public interface arepository extends irepository { }  public interface brepository extends irepository { } 

when invoke findall() on arespository, records in both arepository , brepository. since, inheritance type specified table_per_class, assumed findall() pick records table. added query findall() method detect entity type , pick records appropriately, doesn't seem doing anything. there i'm missing here?

i'm using hibernate underlying persistence framework , working on hsqldb.

thanks,

aarthi

the typing of repositories incorrect change to.

@norepositorybean public interface irepository<entity extends abstractentity> extends repository<entity, long> {  }  public interface arepository extends irepository<a> {  }  public interface brepository extends irepository<b> {  } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -