You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Michael Lepine <mi...@gmail.com> on 2007/11/28 21:55:23 UTC
DataObjectUtils.objectForPK
I noticed that the convenience methods in the DataObjectUtils class only
execute a query if the object is not already cached. Is there a way to force
the methods to issue a query to the database? I've included an excerpt of
the javadocs for 2.0 below.
public static DataObject
<http://cayenne.apache.org/doc20/api/cayenne/org/apache/cayenne/DataObject.html>
*objectForPK*(ObjectContext
<http://cayenne.apache.org/doc20/api/cayenne/org/apache/cayenne/ObjectContext.html>
context,
java.lang.Class dataObjectClass,
java.lang.Object pk)
Returns an object matching an Object primary key. If the object is mapped
to use a compound PK, CayenneRuntimeException is thrown.
If this object is already cached in the ObjectStore, it is returned without
a query. Otherwise a query is built and executed against the database.
Thanks for the help.
- Mike
Re: DataObjectUtils.objectForPK
Posted by Michael Lepine <mi...@gmail.com>.
Okay, thank you.
On Nov 28, 2007 3:06 PM, Aristedes Maniatis <ar...@ish.com.au> wrote:
>
> On 29/11/2007, at 7:55 AM, Michael Lepine wrote:
>
> > I noticed that the convenience methods in the DataObjectUtils class
> > only
> > execute a query if the object is not already cached. Is there a way
> > to force
> > the methods to issue a query to the database?
>
> After you get the object you can set its persistent state to HOLLOW.
> Then the next time you access its attributes, the object will be
> refaulted from the database.
>
> Ari
>
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001 fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
>
>
>
Re: DataObjectUtils.objectForPK
Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 29/11/2007, at 7:55 AM, Michael Lepine wrote:
> I noticed that the convenience methods in the DataObjectUtils class
> only
> execute a query if the object is not already cached. Is there a way
> to force
> the methods to issue a query to the database?
After you get the object you can set its persistent state to HOLLOW.
Then the next time you access its attributes, the object will be
refaulted from the database.
Ari
-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A