Re: Internal Data Type for BOOL
Re: Internal Data Type for BOOL
- Subject: Re: Internal Data Type for BOOL
- From: Art Isbell <email@hidden>
- Date: Tue, 3 Jun 2003 15:57:08 -1000
Different databases handle boolean datatypes in different ways, some
more seamlessly than others. But all databases handle integer
datatypes seamlessly, so making booleans integers should work across
all databases.
After struggling somewhat with boolean data, I finally decided to
adopt someone's suggestion on how to store booleans as integers.
Basically, model booleans as integers in your eomodel. Name the
boolean attribute with something like an "Int" suffix - e.g.,
isActiveInt. EOModeler's generated Java class file will contain
isActiveInt() and setIsActiveInt() accessors. Add 2 more accessors
that you will actually use in your WO apps including in WO component
bindings:
public boolean isActive() {
Number isActive = isActiveInt();
return ((isActive != null) && (isActive.intValue() == 1));
}
public void setIsActive(boolean aFlag) {
setIsActiveInt(new Integer(aFlag ? 1 : 0));
}
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.