Re: Creating an EOEditingContext object
Re: Creating an EOEditingContext object
- Subject: Re: Creating an EOEditingContext object
- From: Chuck Hill <email@hidden>
- Date: Sun, 25 Apr 2004 20:05:09 -0700
Please reply to the list.
Is App1 an Entity in your EOModel? If not, you need go back and re-read
some of the tutorials. If it is an entity, you've not added the EOModel to
the project correctly. What are you using for an IDE? Which OS?
Chuck
At 07:52 PM 25/04/2004 -0700, Ismael Nass-Duce wrote:
>>>>
Hi Chuck,
Thank you for your feedback.
Please bear with me. I am new to WO and I feel a little bit lost.
Here's what I am trying to do:
I created a Java Client app for adding and modifying database
records for the different entities defined in my eomodel. This works
fine.
Then, I created a new WebObjects Application project that supports
web services and that uses the same model I used in the Java Client.
What I want to do, is use the resulting app as a request processing
module that receives requests and fetches records based on the information
requested.
For example, I a may need to look up an applications whose name is App1.
I am not doing this from in the context of Session, DirectAction, and
WOComponent subclasses.
If I try
EOEditingContext editingContext = new EOEditingContext();
editingContext.lock();
try {
EOFetchSpecification fetchSpec = new EOFetchSpecification("App1", null,
null);
obList = editingContext.objectsWithFetchSpecification(fetchSpec);
System.out.println("Number of matching records: "+ obList.count());
} finally {
editingContext.unlock();
}
I get an error message:
java.lang.IllegalArgumentException: An object store for the entity "App1"
could not be found. Verify that the entity is defined in an EOModel, and
that the model is installed properly. To see what models are loaded, you
can try printing the return value of EOModelGroup.defaultGroup() in your
application.
Any ideas?
Ismael
On Apr 25, 2004, at 7:22 PM, Chuck Hill wrote:
I don't know where the heck you've been "gathering" that from!
Dude. Dude. It's WebObjects. Its easy to do things like this. The hands
down simplest way is to use
session().defaultEditingContext(). That will only work in the context of
Session, DirectAction, and WOComponent subclasses. If you need one
someplace else:
EOEditingContext ec = new EOEditingContext();
ec.lock();
try {
// your code goes here
}
finally {
ec.unlock();
}
Chuck
P.S. Your model would be best placed in a framework for ease of reuse.
At 07:11 PM 25/04/2004 -0700, Ismael Nass-Duce wrote:
Hi,
How can I create an EOEditingContext object that I can use to
access records from a database.
I created a WebObjects application, which uses the same EO model
that I used for WebObjects Java Client.
I want to use the objectsWithFetchSpecification() or
EOUtilities.objectsForEntityNamed()
methods to fetch objects from the database.
>From what I can gather, I'll need to do the following:
| - construct a model from a file
| - create a EODatabase from that model
| - create an EOQualifier with format
| - create an EOFetchSpecification with entity
| - retrieve an EOEditingContext from EODatabase
Is there sample code that applies these steps?
Ismael
_______________________________________________
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.
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
<<<<
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
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.