java - create object in hibernate select -
i have 2 classes:
class { b b; public a() {} public a(b b) { setb(b); } ... } class b { int id; public b(int id) { setid(id); } }
in hql want select this:
select new a( new b(a.b.id) ) a
but got error
org.hibernate.hql.parser - line 1:48: unexpected token: ,
is possible create object in parameter, or select field , create inside constructor?
not sure whether understood want achieve. can create hql query (with projection) query columns you're intereset in, like:
select a.whatever, b.id a join a.b b
afterwards provide implementation interface resulttransformer , set query
object query.setresulttransformer(yourtransformer)
your implementation of result transformer responsible creating instances a
, b
Comments
Post a Comment