I have a VO class which has the getter and setter of another VO class too. For example:
Class DocumentVO{
PrintJobVO job;
PrintRunVO run;
String id;
getters and setters..
}
Now I have a requirement to use the Native SQL Query using spring hibernate. When I want to map the ids I have a problem. My query is,
select {r.*},{d.*}
from runs {r}, documents {d}
where {r}.RUN_ID as {r.id} = d.RUN_ID as {d.run.id}
Here run
is of type PrintRunVO which has its id and other values. How can I map them in my SQL? I am getting an error like invalid user.table.column, table.column, or column specification
.
What's the way to overcome this?
From stackoverflow
-
Use the Result Transformer concept in your plain SQL query.
String query = "myquery"; SQLQuery q = session.createSQLQuery(query); q.addScalar("param1", Hibernate.STRING); q.addScalar("param2", Hibernate.STRING); q.setResultTransformer(Transformers.aliasToBean(MyVO.class)); q.setParameter("queryParam1", "some value"); return q.list();
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.