• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ERXMutableArray fields in Entity Modeler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ERXMutableArray fields in Entity Modeler


  • Subject: Re: ERXMutableArray fields in Entity Modeler
  • From: "Daniele Corti" <email@hidden>
  • Date: Fri, 18 Apr 2008 16:07:37 +0200

well, Usually I create a  ByteArrayOutputStream, and initilize an ObjectOutputStream with it, then i write out the object (ObjectOutputStream.writeObject(Object o)) I want to convert in bytes and initilize an NSData with them (new NSData(ObjectOutputStream.toByteArray()) ).

To read from the DB, I made the inverse: ByteArrayInputStream  -> ObjectInputStream.readObject(), and get the object i've written before.

Remember Method to get NSData is public, no arguments, method to convert to the object is public static one argument NSdata.

Have a look to Java API http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectOutputStream.html, http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectInputStream.html

2008/4/18 Jeff Schmitz <email@hidden>:
I received one suggestion to define a serializable class to contain the array and then serialize the array objects to the NSData/BLOB type, instead of ERXMutableArray.  I may  give that a try.  Is that a viable approach?  Any examples out there of doing this?

Thanks,
Jeff


On Apr 18, 2008, at 1:26 AM, Denis Frolov wrote:

Hi,

I had a similar problem with MySQL (mysql-connector-java-5.0.4-bin.jar
is the latest one I've tried) and mutableDictionary. There were two
solutions that worked for me:

1. Change externalType to TEXT in model while leaving BLOB in the
database (i.e. generate sql with TEXT and change type to BLOB after
that).
2. Modify generator templates to have something like:

 public er.extensions.ERXMutableDictionary uploadsFileNames() {
      try {
          return (er.extensions.ERXMutableDictionary)
storedValueForKey("uploadsFileNames");
      } catch (ClassCastException e) {
          return (ERXMutableDictionary)
ERXMutableDictionary.fromBlob((NSData)
storedValueForKey("uploadsFileNames"));
      }
  }

Both solutions are really dirty and can lead to unwanted side effects,
so I've decided that it really doesn't worth the effort and refactored
my model not to use these prototypes at all.

You might also want to check this thread:
http://www.wodeveloper.com/omniLists/webobjects-dev/2004/March/msg00340.html

On Thu, Apr 17, 2008 at 3:20 PM, Jeff Schmitz <email@hidden> wrote:
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?



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.saveChanges();

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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

Hope this Help

--
Daniele Corti
AIM: S0CR4TE5
Messenger: email@hidden

--
Computers are like air conditioners -- they stop working properly if you open
WINDOWS

--
What about the four lusers of the apocalypse? I nominate:
"advertising", "can't log in", "power switch" and "what backup?"
--Alistair Young
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >ERXMutableArray fields in Entity Modeler (From: Jeff Schmitz <email@hidden>)
 >Re: ERXMutableArray fields in Entity Modeler (From: "Denis Frolov" <email@hidden>)
 >Re: ERXMutableArray fields in Entity Modeler (From: Jeff Schmitz <email@hidden>)

  • Prev by Date: Re: Project Wonder : Database Migration : Downgrade
  • Next by Date: Import Windows WebObjects 5.2.4 projects into OS X WebObjects 5.4
  • Previous by thread: Re: ERXMutableArray fields in Entity Modeler
  • Next by thread: RE: ERXMutableArray fields in Entity Modeler
  • Index(es):
    • Date
    • Thread