I have an entity object that contains both persistent and transient data. The transient data from DetailTable and the persistent data comes from tableX. This entity is meant to be the detail entity in a master - detail relationship.
Code:
@NamedNativeQuery(
name= "detail",
query = "SELECT * FROM DetailTable"
resultSetMapping ="detailMapping")
@SqlResultSetMapping(name="detailMapping",
entities={@EntityResult(
entityClass=VoucherItem.class,fields={@FieldResult(name="transientField",column="detailField")})})
@Entity
@Table(name = "tableX")
public class Detail implements Serializable() {
@Basic
private String persistentField
@Transient
private String transientField
}
The master entity has a collection of the detail entity
Code:
@OneToMany(fetch=FetchType.LAZY, cascade={CascadeType.ALL})
@JoinColumn(name="detailID")
private Collection<Detail> detail = new ArrayList<Detail>();
public Collection<Detail> getDetail() {
return detail;
}
public void setDetail(Collection<Detail> detail) {
}
My question is how do I call the named query in the detail entity that loads the transient data?