java - jpa native query control entity(part 3) -


  • retrieve company table
    getentity.java

    string table = "company"; string q = "select * " +table;  query query = em.createnativequery(q, company.class); list<company> list = query.getresultlist(); ... 
  • retrieve staff table
    getentity.java

    string table = "staff"; string q = "select * " +table;  query query = em.createnativequery(q, staff.class); list<staff> list = query.getresultlist(); ... 
  • my questions how control ? following:

    em.createnativequery(q, ?); list<?> list = q.getresultlist(); 

    any ideas or suggestion?

another option pass class entityclass argument find method , can try , derive table name entityclass using reflection , use entityclass type argument createnativequery method.

hope helps!


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -