-->
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: CompositeUserType for Multi-Column Flags
PostPosted: Thu Sep 20, 2007 10:42 am 
Beginner
Beginner

Joined: Thu Dec 01, 2005 1:09 pm
Posts: 33
This actually concerns NHibernate and I have posted the same question over here, but as I haven't received a reply yet, I decided to ask here, too.
Just in case you should wonder why my Java is a little rusty.

I have some flags like this:

Code:
public static final int NOTHING = 0;
public static final int FOO = 1;
public static final int BAR = 2;
public static final int FUZZ = 4;


These flags map to several columns, FLAG_FOO, FLAG_BAR and FLAG_FUZZ.

As my database doesn't support booleans, those columns are of type nullable char(1) with 'X' meaning "true" and null meaning "false". I have implemented a UserType ("CharBooleanType") for such columns when used alone.

How can I have those three columns as one bit vector and still be able to use the columns in the WHERE part of the query?
Like "where Flag.Foo is not null" or something.
My current implementation implements UserType, so getting the flags combined into one int is not a problem, I only struggle with querying the columns.
I have read that implementing CompositeUserType instead will do the job.

But what will I have to do for my implementation to support those "char booleans?"
What should getPropertyTypes() return?
Why are both get/setPropertyValue and nullSafeGet/Set methods required?
What should isMutable return?

Unfortunately I could hardly find any information online, so any help will be highly appreciated.

/Marvin


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.