JPA Mapping embedded fields with createNativeQuery -


i have entity has field represents composite primary key annotated embeddeid , field annotated embedded annotation. both of these fields not directly mapped the columns returned query passed createnativequery method. getresultlist returns me list of entities, 2 fields mentioned null in entities.

public interface key{  public int hashcode() }  @embeddable public class compositepk impements key{    private int empid;    private date startdate;    private date enddate; }  @embeddable public class partitionkey implements key{    private string empname; }  @entity public class employee {  @embeddedid  private compositepk id;   @embedded  private partitionkey name;   @column(name="empid")  private int empid;   @column(name="empname")  private string empname;   @column(name="startdate")   private date startdate;   @column(name="enddate")   private date enddate;      }  public class loader{  private static entitymanager em;  public static void main(string [] args){  //code instantiate em goes here  //...  //....  query query = em.createnativequery("select empid,empname,startdate,enddate employees", employee.class );  list entities = query.getresultlist();  //print list  system.out.println(entities);  } } 

the outcome of entities populated fieldsid , name emdedded fields null. can please suggest how populate these 2 fields?

thanks


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -