I have a named native query and I am trying to map it to the return results of the named native query. There is a field that I want to add to my entity that doesn’t exist in the table, but it will exist in the return result of the query. I guess this would be the same with a stored proc…
How do you map the return results of a stored proc in JPA?…
How do you even call a stored proc?
here is an example query of what I would like to do…
select d.list_id as LIST_ID, 0 as Parent_ID, d.description from EPCD13.distribution_list d
The Result will be mapped to this entity…
public class DistributionList implements Serializable {
@Id
@Column(name="LIST_ID")
private long listId;
private String description;
private String owner;
private String flag;
@Column(name="PARENT_ID", nullable = true)
private long parentID;
}
parent ID is not in any table in my database. I will also need to use this entity again for other calls, that have nothing to do with this call, and that will not need this parent_id? Is there anything in the JPA standard that will help me out?
If results from database are not required for further manipulation, just for preview, you can consider using database view or result classes constructor expression.
If entities retrieved from database are required for further manipulation, you can make use of multiple select expression and transient fields.