cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Help with FK
Date Tue, 12 Nov 2013 08:05:43 GMT
Hi Andres,

First you will need to map a relationship based on your FK/PK pair (both DbRelationship and
ObjRelationship) [1]. Once you have that in the model and regenerate your java classes, your
Ordencompra object will have a method like ‘getCotizacions’, returning a collection of
related objects. So you can use that. Or you can build a query based on a know Ordencompra
as a criteria:

Ordencompra o = ..
SelectQuery q = new SelectQuery(Cotizacion.class);
q.andQualifier(ExpressionFactory.matchExp(Cotizacion.ORDENCOMPRA_PROPERTY, o);

Hope this helps,


On Nov 10, 2013, at 10:38 PM, Andres L. <> wrote:

> I have some tables. One of them called COTIZACION with fields
> "idProveedor", "idOrdenCompra", and "fecha" (date), where "idProveedor" and
> "idOrdenCompra" are FK to tables PROVEEDOR and ORDENCOMPRA. When I make a
> query by id  from ORDENCOMPRA (which is ORDENCOMPRA PK) and I get the
> value, I need to get the COTIZACION value that has a relationship with
> ORDENCOMPRA. How can I make it?
> Thank you in advance.

View raw message