Re: Can I have Editing context managed my objects that returned from raw-row SQL?
Re: Can I have Editing context managed my objects that returned from raw-row SQL?
- Subject: Re: Can I have Editing context managed my objects that returned from raw-row SQL?
- From: Arturo PĂ©rez <email@hidden>
- Date: Wed, 19 Feb 2003 21:43:07 -0500
On miircoles, febr 19, 2003, at 20:03 America/Mexico_City, Tom M.
wrote:
Hi all,
I used SQL to get my data from database in the form of
raw row (NSDictionary object). Then I create EO
objects from raw rows returned above?
How can I have Editing Context manage my objects, mean
that I can transver relationship..., and use the
benefits of EOF.
A 7 line tutorial given that you have a working EOModel. Assume your
model contains an object named
CarModel with a relationship named manufacturer and two attributes
named (name, numCylinders). Then
carsWithEightCylinders =
EOUtilities.objectsMatchingKeyAndValue(defaultEditingContext,
"CarModel", "numCylinders", new Integer(8));
for (int i = 0; i < carsWithEightCylinders.count(); i++) {
EOGenericRecord eo =
(EOGenericRecord)carsWithEightCylinders.objectAtIndex(i);
System.out.println(eoc.valueForKey("manufacturer") + " makes an eight
cylinder car named " +
eo.valueForKey("name"));
}
If you actually create a Java class for CarModel with EOModeller then
the code above becomes
carsWithEightCylinders =
EOUtilities.objectsMatchingKeyAndValue(defaultEditingContext,
"CarModel", "numCylinders", new Integer(8));
for (int i = 0; i < carsWithEightCylinders.count(); i++) {
CarModel car = (CarModel)carsWithEightCylinders.objectAtIndex(i);
System.out.println(car.manufacturer() + " makes an eight cylinder car
named " +
car. name());
}
Does that help any?
-------
WebObjects in Philadelphia. You want a cheesesteak with that?
_______________________________________________
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.