0

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?

1 Answer 1

1

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.