java - call stored procedure JPA 2.1 Repository with Spring -
i'm trying call stored procedure in mysql call: "searchcontext".
i have tried solution : here , here
but how can entitymanager reference? if i'm using jpa repositories this:
public interface activecontextrepository extends jparepository<activecontext, long> { activecontext findbyiduser(integer iduser); }
i got null pointer when use entitymanager this:
public class contextservice { @persistencecontext protected entitymanager entitymanager; public entitymanager getentitymanager() { return entitymanager; } public integer getcontext(integer iduser, string date, double longitude, double latitude){ storedprocedurequery storedprocedure = entitymanager.createstoredprocedurequery("searchcontext"); }
or this:
public class contextservice { @autowired entitymanager entitymanager; public integer getcontext(integer iduser, string date, double longitude, double latitude){ storedprocedurequery storedprocedure = entitymanager.createstoredprocedurequery("searchcontext"); }
i haved tried solution:here precompiler gives me error on jpa repository:
"invalid derived query!no property search found type activecontext"
thank much!
i have resolved problem. making "new() " of class wich have new entity manager...nie injected "autowire" , bean declared in application-config thank
Comments
Post a Comment