java - How do I map another column into Hibernate bean? -
java - How do I map another column into Hibernate bean? -
i have object mapped hibernate using hbm.xml file. bean/object table includes field, appropriate getter/setters. want like:
select t.*, 'xyz' otherdata table t
and have info mapped bean, including value of fake/additional column - 'otherdata.'
this should simple , maybe i'm missing easy, cant work. i've tried using
createsqlquery() addentity(), addscalar(), setresulttransformer()
and
createcriteria() projectionlist() , setresulttransformer()
and whatever else can think of , nil gives desired results. dont want generic list of objects have parse through build objects, , don't want have specify every column of table while building query.
is there way can done?
you might consider using formula property. can fill sql query data. consider illustration order - order line relation want fill property of order number of order lines, like:
public class order { private string ordernumber; private int linecount;
... }
then mapping be:
<class name="order" ....> ... <property name="linecount" formula="(select count(*) order_line l l.order_number = order_number)"/> ... </class>
java hibernate criteria
Comments
Post a Comment