Originally posted by Rashmi Tambe:
Hi ,
I have an entity bean that maps to table having a column with datatype as varchar2(1). for e.g. the column name is empty.
This column is treated as a boolean flag. The enetity bean has methods ,
Boolan isEmtpy()
setEmpty(Boolean b)
The problem is when i set it as setEmpty(Boolean.TRUE). value 1 is inserted in database. How can i insert 'Y'/'N' instead os 1/0 using CMP?
I am using oracle8i.
Thanks in advance.
so isEmpty and setEmpty are abstract methods for setting / getting the "empty" CMP field? Does weblogic do this varchar --> boolean conversion for us? W'd be great if you c'd confirm this for me.
I thought weblogic expects us to use BIT data type / SMALLINT (cant recollect actually!) for the column type in the DB to map it to a boolean field in the bean.
Either way, you still can persist "Y" / "N" (which i dont personally prefer when you have a bit ( 1 / 0) to indicate false / true) by converting the abstract setters and getters to return/accept a
String instead.
Then you can ofcourse do a setEmpty("Y").
or you can provide a different public getter/ setter in the bean that actually interpret the String and return / set a boolean value.