Friday, July 18, 2008

Use of formula to concate fields

Suppose you have two fields holding firstname and lastname. And there is a property called fullname which is expected to hold the concatinated firstname and lastname. Then you have to do like follows...


Define a property called fullname in its class

Then in .hbm file, put a porperty like

<property name="fullName" formula="concat(FIRST_NAME,
LAST_NAME)"/>



Remember: FIRST_NAME and LAST_NAME are the database field name and not the class properties. Only two fields can be concatinated. No. of arguments mismatched exception may occur if more than two fields are concatinated.

No comments:

Post a Comment