-
1. Re: SelectBooleanCheckbox and Y/N mapping
pmuir Aug 3, 2007 5:48 AM (in response to nickarls)You need to write a converter ;) I think you want to return "true" and "false" as the String.
-
2. Re: SelectBooleanCheckbox and Y/N mapping
nickarls Aug 3, 2007 7:32 AM (in response to nickarls)The problem is that such a converter doesn't get called (e.g. discussion on http://forum.java.sun.com/thread.jspa?threadID=500387)
-
3. Re: SelectBooleanCheckbox and Y/N mapping
pmuir Aug 3, 2007 7:40 AM (in response to nickarls)Ok, then as Adam says this is a bug in the spec (IMO). I don't know about your data model, but if you can alter the entity bean to have booleans, then you can use hibernate to map these back to strings in the database.
-
4. Re: SelectBooleanCheckbox and Y/N mapping
smithbstl Aug 3, 2007 9:47 AM (in response to nickarls)Pete, I am interested in this as well, specifically mapping Boolean in entities to non-boolean database fields (Oracle, ugh). I have Boolean represented in Oracle as non-null 1's and 0's. I have read that you can use Hibernate query substitutions to get around this problem, is this what you are referring to in your previous post or is there some other way?
Thanks -
5. Re: SelectBooleanCheckbox and Y/N mapping
pmuir Aug 3, 2007 12:13 PM (in response to nickarls)I was talking about hibernate user types. Hibernate actually has built in usertypes for a few different ways of representing true/false
-
6. Re: SelectBooleanCheckbox and Y/N mapping
nickarls Aug 3, 2007 2:43 PM (in response to nickarls)public class ZeroOneType extends CharBooleanType { protected final String getTrueString() { return "1"; } protected final String getFalseString() { return "0"; } public String getName() { return "zero_one"; } }
Yep, I'm currently trying out something like the above with a
@Type(type=foo.ZeroOneType) annotation. Lets see how it works out.
I've come to the conclusion with all converters etc that my domain objects have some traces of legacy-db-reverse-engineering. I'm now working towards making them more natural (booleans are booleans, enums are enums)... -
7. Re: SelectBooleanCheckbox and Y/N mapping
pmuir Aug 4, 2007 6:06 AM (in response to nickarls)Exactly, this is, IMO, the "right" way to do it. You want your domain model as represented by entity beans to be "correct", and use hibernate to map it to your legacy schema. You should just use JSF converters for converting from the correct model to display and back.