Well I finally came across a solution to my problem. I figured I'd post it in case anybody else is having a similar issue...
The key is to use @SqlResultSetMapping in conjunction with @NamedNativeQuery. The code looks something like this:
Code:
package com.test.model.entity.dept
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityResult;
import javax.persistence.Id;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;
@Entity
@SqlResultSetMapping(name = "implicit_mapping", entities = @EntityResult(entityClass = com.test.model.entity.dept.DeptActivity.class))
@NamedNativeQuery(name = "DeptActivity",
query = "SELECT " +
"d.DEPT_ID as deptName, " +
"da.ACTIVITY_ID as activityName " +
"FROM " +
"DEPT d INNER JOIN " +
"DEPT_ACTIVITY da ON d.CHRONICLE_OID = da.DEPT_OID INNER JOIN " +
"WHERE " +
"(d.DEPT_OID = :deptOid) " +
"GROUP BY " +
"da.ACTIVITY_DT",
resultSetMapping = "implicit_mapping")
public class DeptActivity
{
private String deptName;
private String activityName;
@Id
@Column
public String getDeptName()
{
return deptName();
}
@Column
pubic String getActivityName()
{
return activityName();
}
Then you can refer to the query and replace the variables as such:
Code:
Query query = session.getNamedQuery("DeptActivity");
query.setLong("deptOid", 56L);
List<DeptActivity> list = query.list();
Hopefully this is helpful for others...