Hello,
I'm using Hibernate 3.0.5.
I have created a custom type implementing UserType interface and in nullSafeGet method I access a different database table than the one the custom type field belongs to:
Code:
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException,
SQLException {
if (owner == null) {
return EMPTY_STRING;
}
Session session = HibernateSession.currentSession();
String query = "SELECT ...."
Query q = session.createQuery(query);
String value = (String) q.uniqueResult();
return value;
Also, the returned class of this custom type is String:
Code:
public Class returnedClass() {
return String.class;
}
Inside POJO class there is declared a field as String and the relation with the custom type exists only at hbm level:
Code:
<property
name="name"
column="name"
>
<type name="customType">
</type>
</property>
I know that text-based search using "like" or ordering is not working for custom types.
There is any possibility this can be done without writing all queries to search that second table explicitly ?
Thanks