RE: ERXMutableArray fields in Entity Modeler
RE: ERXMutableArray fields in Entity Modeler
- Subject: RE: ERXMutableArray fields in Entity Modeler
- From: email@hidden
- Date: Thu, 17 Apr 2008 14:52:19 -0700
-------- Original Message --------
Subject: Re: ERXMutableArray fields in Entity Modeler
From: Jeff Schmitz <email@hidden>
Date: Thu, April 17, 2008 2:34 pm
To: email@hidden
Cc: email@hidden
Hi Ray, Thanks for your response, and yes, I think you understand. I was hoping to not have to create a new table with just a boolean column along with a relationship and that I could somehow just store an array in one of the attribute fields directly for the same effect. I assumed that's what ERXMutableArray class was for. If not that, then what is it usually used for?
Thanks,
Jeff
This might not be the most sophisticated solution, but you might consider storing your booleans in the database as a bit field. Store a 32 bit integer and you have 32 booleans and you can provide accessor methods in your business logic that returns the info however you want. You can even use KVC so that some arbitrary labels match up with specific bit positions. You can write all the accessors (for better documentation) or use objectForUnboundKey (check the doc for exact) to respond to an
arbitrary KVC to your object.
There are lots of ways to do it. Some might be less workable in the future, but it depends on what you need to do.
- ray
On Apr 17, 2008, at 3:35 PM,
email@hidden wrote:
-------- Original Message --------
Subject: ERXMutableArray fields in Entity Modeler
From: Jeff Schmitz <email@hidden>
Date: Thu, April 17, 2008 4:20 am
To: WebObjects Mailing List <email@hidden.com>
Hello, I've taken Dave's SooperSeekrit Screencast project as a starting point to start playing with EO objects using the Wonder Framework.
Using Entity Modeler (with Frontbase prototypes), I've added an ERXMutableArray to one of my classes that I want to use as an array of Boolean's in my code. In this case, what do I need to put as the Value Type? Also, for the width, will it be 4 bytes X the max number of Booleans to be stored?
<snip>
I have tried just leaving these fields blank.
Then using the following code, I'm able to create a User object ok, and it shows up in my database with the Boolean array as a Blob:
Group group = Group.fetchRequiredGroup(ec, "name", "user");
Boolean [] bools = {true, false, true};
ERXMutableArray boolArray = new ERXMutableArray(bools);
User.createUser(ec, boolArray, first, last, password, newuser, group);
ec.saveChang es();
However, when I try to a fetch from the DirectAction class as follows:
EOQualifier qual = User.USERNAME.eq(username).and(User.PASSWORD.eq(password));
User user = User.fetchRequiredUser(ERXEC.newEditingContext(), qual);
I get the following exception on the User.fetchRequiredUser line:
Apr 16 22:31:32 SooperSeekrit[49595] (ERXDatabaseContextDelegate.java:105) INFO er.transaction.adaptor.Exceptions - Database Exception occured: java.lang.ClassCastException: er.extensions.ERXMutableArray
I'm guessing it has to do with the missing fields?
Thanks,
Jeff
I might be misunderstanding your question or what you are trying to do. But I think that you are not going to be able to do this as you describe.
The picture you show is for the Properties of an attribute value. In other words, if you are returning an array of booleans, then you somehow have a to-many relationship that is returning some number of value attributes. Those value attributes are of t ype boolean. The relationship is, in an object-oriented sense, an attribute also. But it is not a value attribute.
If you look at a relationship in a model, and look at its Properties, you will see what can be done with a relationship.
Does this make sense?
- ray
<erxmutablearray.jpg> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (Re: I wonder if you have seen this before: exec: -X: invalid option
Next by Date:
Re: ERXMutableArray fields in Entity Modeler
Previous by thread:
Re: ERXMutableArray fields in Entity Modeler
Next by thread:
"First request in session" problem and a bug in WOComponentRequestHandler
Index(es):