Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to represent a boolean attribute

107137Jul 19 2002
Sorry, obviously this is a "very stupid user" question, but to say the truth, I didn't find the clue yet.

What is the best way to store a simple boolean in an entity object connected to an Oracle9i database?
Sounds easy, but is not.

Unfortunately Oracle has no "BIT" or "BOOLEAN" Datatype, so you have to use a different one. I thought "CHAR(1)" should be suitable as this doesn't waste to much of dataspace. Please correct me if you think this is wrong!

Doing this I can match this column of Type "CHAR(1)" to several java datatypes. JDeveloper defaults to "String" for CHAR(1). But what I really want, is to match this Column to a "Boolean" as I would like to set my attribute like this: Row.setIsConfidential(true). Unfortunately this is not possible, as there is no cast from Boolean to char.

Do I really have to handcode the translation code to translate a simple boolean to something like "T" or "F" which I can store in my Database? I think there must be a better way!

Any hints are appreciated

Frank
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2002
Added on Jul 19 2002
5 comments
1,162 views