-->
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.  [ 4 posts ] 
Author Message
 Post subject: UserType in a query
PostPosted: Tue Jan 20, 2004 10:22 am 
Newbie

Joined: Sun Oct 26, 2003 4:46 pm
Posts: 16
Location: Tallinn, Estonia
hello,

One of my mapped classes has a property of type char which is mapped to a char(1) column. This is a status column. The table has a secondary index on this column. As most rows in this table will be in a specific state by which it is not neccessary to locate them, our DBA recommended to store this state as NULL in the database - then it will be left out from the index and speed up index lookups for other statuses.

As I don't want my class to have the status char = 0, I thought a UserType might be a good idea here which maps 'F' to null and just passes through everything else. While it works perfectly on save and load it doesn't seem to use the UserType in queries.

When I do "from Document d where d.owner=? and d.status=?" and then set 'F' to be the value of status, then it actually passes 'F' into the created PreparedStatement. I kind of hoped it used my UserType to convert the 'F' to NULL...

Is this the correct behaviour or am I missing something?

_________________
best regards,
erik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 10:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you really specifying the Type by for example using query.setParameter(int position, Object val, Type type) ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 11:03 am 
Newbie

Joined: Sun Oct 26, 2003 4:46 pm
Posts: 16
Location: Tallinn, Estonia
Quote:
Are you really specifying the Type by for example using query.setParameter(int position, Object val, Type type) ?


well, I am using Session's find(String query, Object[] values, Type[] types) and I specify Hibernate.CHARACTER as the type for that.... I should probably specify something else as the type?

thanks,
erik

_________________
best regards,
erik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2004 11:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hibernate.custom(Usertype.class)


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

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.