I'm pretty sure (but I haven't checked the code, so I could be wrong) that
QueryByExample only uses the primary key. In any case, this is what we have
done to retrieve a specific object:
public PersistantObject retrieve(Class type, long oid)
{
StringBuffer query = new StringBuffer("select o from ");
query.append(type.getName());
query.append(" where oid = ").append(oid);
List list = executeQuery( query );
if (list.isEmpty())
return null;
return (PersistantObject) list.get(0);
}
where PersistantObject is our baseclass for all persistable objects.
Is this what you had in mind?
Dave Derry
----- Original Message -----
From: "Frank Renaers" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 06, 2002 4:25 AM
Subject: Long transactions
> Hi,
>
> Since Long Transactions are currently not support in OJB, I am
> building my own 'Long Transaction' manager.
> Before an OJB object will be updated, I need to retrieve first
> the 'OLD' object to compare the timestamps.
> To do this, I need a kind of 'QueryByPrimaryKey' .
> It 's almost the same as a QueryByExample, but only the primary key
> may be used. The values of the other fields may be ignored.
>
> Does someone know how to implement a generic QueryByPrimaryKey ??
>
> Thanks,
>
> Frank Renaers
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>