-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate custom types - text-based search and order-by
PostPosted: Wed Dec 13, 2006 4:37 am 
Newbie

Joined: Wed Dec 13, 2006 4:18 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.