Search code examples
javaspringhibernatedto

Map query results to property


Is there way to set results of a query to java DTO property using hibernate ?

Something like,

<hibernate-mapping>

<class name="myDTO" table="my_table">
    <property name="myProperty" query="what_i_need" />
</class>

<query name="what_i_need">
        <![CDATA[
        from    .....
        ]]>
</query>

</hibernate-mapping>

I'm using spring, hibernate, java.


Solution

  • If I understand you correctly @josef-prochazka 's suggestion of using a formula would be what you need.

    See also: