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,
Andrus

[1] 
http://cayenne.apache.org/docs/3.1/tutorial/ch03.html#mapping-db-relationships

On Nov 10, 2013, at 10:38 PM, Andres L. <[email protected]> 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.

Reply via email to