Spring Data Rest (SDR) error: PersistentEntity must not be null -


i'm working expose spring data repositories via sdr. when navigate rest url (http://localhost:8080/trxes), error: {"cause":null,"message":"persistententity must not null!"}

on closer inspection of spring data source, see getrepositoryfactoryinfofor() method returns empty repository information i.e.

private repositoryfactoryinformation<object, serializable> getrepositoryfactoryinfofor(class<?> domainclass) {      assert.notnull(domainclass, "domain class must not null!");      repositoryfactoryinformation<object, serializable> repositoryinfo = repositoryfactoryinfos.get(classutils             .getuserclass(domainclass));     return repositoryinfo == null ? empty_repository_factory_info : repositoryinfo; } 

the probable reason problem persistent entities inherit single base class, , i'm using single table strategy follows:

there trx table in database matching trx class. variableincome, variableexpense, fixedincome , fixedexpense inherit trx , persist trx table.

    @entity     @table(name = "trx")     @inheritance(strategy = inheritancetype.single_table)     @discriminatorcolumn(name = "trx_type", discriminatortype = discriminatortype.string)     abstract public class trx extends abstractpersistable<long> { 

all subclasses similar variableincome shown below:

    @entity     @discriminatorvalue("variable_income")     public class variableincome extends trx { 

my repository setup (no annotations on class):

public interface trxrepository extends crudrepository<trx, long> { 

i run described setup using:

@springbootapplication public class restapplication {      public static void main(string[] args) {         springapplication.run(restapplication.class, args);     }  } 

i guess i'm looking whether there's way of telling sdr (when tries deduce persistent classes are) subclasses should map trx?

this issue on "rest" side , less on "data" side.

you need use jackson annotations type information.

@jsontypeinfo(use=jsontypeinfo.id.class, include = as.property, property = "@class") 

you can find more here, there few ways structure depending on use case , preference.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -