Hi,
think of the following scenario: you have a class Person with firstname and surename, both with getters and setters.
Since your table is large you want to avoid a full table scan when doing queries and therefore introduce an additional "SEARCH_NAME" column with an index.
In the Java class you have a derived attribute returning this search name:
public String getSearchName() { return getFirstname() + getSurname(); }
If I use
<property name="SearchName" column="SEARCH_NAME" length="80" type="java.lang.String" not-null="true" index="IDX_SEARCH_NAME"/>
I get an error that there is no "setter" method for this property on the Java class - but since it is derived I dont want to provide a setter method.
How would one map these in the *.hbm.xml file, so that:
- the search name is persisted too
- I dont have to provide a setter (since it is computed)
Is there something like a "write-only" property?
Thx
T.
|