Hi,
By default, Cayenne Modeler hides the primary key information of your object
entities.
You should look at the DataObjectUtils class that provide some very usefull
methods to access primary key of persistent objects and to get persistent
objects from their primary key.
For ex. if you use interger primary keys :
DataObject org.apache.cayenne.DataObjectUtils.objectForPK(ObjectContext
context, Class dataObjectClass, int pk)
int org.apache.cayenne.DataObjectUtils.intPKForObject(Persistent dataObject)
With that, you can get the ID of any persistent object and get an object by
its ID.
To delete an object, you don't have to code any SQL query, just use the API
from the DataContext class.
Pierre
On Tue, Dec 9, 2008 at 5:49 PM, Filipe Costa <nevco..mail.com> wrote:
> Hi all,
>
> I'm creating a new project and I chosed to use Cayenne 2.4.
>
> The thing is that I want to make a simple "Select By Id" query (auto
> generated id), but it seems it is not possible! Can anyone help me?
>
> If there are no way of selecting by an Id, how you can make basic
> functionality like a table where you can delete some specific row? "Delete
> USER where name = 'name'" is not a good option... neither creating a new
> key
> column to do this.
>
> Thanks in advance.
>
> Cheers
>
-- Cordialement, Pierre Lavignotte Ingénieur Conception & Développement http://pierre.lavignotte.googlepages.com
This archive was generated by hypermail 2.0.0 : Tue Dec 09 2008 - 11:58:14 EST