I am trying to return a list in jsp from jsp:useBean and I tried the query working in mysql database. Somehow this query always return null and throw an exception on eclipse and it won't stop at break points:
@Query(value="SELECT * FROM customize_service WHERE account_id=:acctid AND biz_id=:bizid and active=:active",
nativeQuery=true)
public List<Service> getServices(@Param("acctid") String acctid, @Param("bizid") String bizid, @Param("active") int active);
Stuck, hope someone can help!
Newbie
CodePudding user response:
Native query returns object only
use this one:
public List<Object> getServices(@Param("acctid") String acctid, @Param("bizid") String bizid, @Param("active") int active);
CodePudding user response:
Service interface is used for encapsulates the application's business logic and Entity or Model class represents a Java object carrying data. in your case you pass Service as a Object in List but reality is to pass Entity name or Object[] because Service interface don't have variable to Set or Get data...
If you want get data using Getter pass Entity or Model:
public List<Entity> getServices(@Param("acctid") String acctid, @Param("bizid") String bizid, @Param("active") int active);
If you want to get data without using Entity pass Object[]:
public List<Object[]> getServices(@Param("acctid") String acctid, @Param("bizid") String bizid, @Param("active") int active);
