jpa native query retrieve multiple entities
问题 I have a database with 4 tables: company,staff,department,project Company.java @Entity @Table(name = "company") @SqlResultSetMapping(name = "COMPANY", entities = { @EntityResult(entityClass = Company.class), @EntityResult(entityClass = Staff.class) }) ... GetEntity.java EntityManagerFactory emf = Persistence.createEntityManagerFactory("GetEntityPU"); EntityManager em = emf.createEntityManager(); String query = "SELECT * FROM company c JOIN staff s ON c.ID = s.companyID"; Query q = em