FAQ
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.

Search Discussions

  • Andrus Adamchik at Nov 12, 2013 at 8:06 am
    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. 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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedNov 10, '13 at 7:39p
activeNov 12, '13 at 8:06a
posts2
users2
websitecayenne.apache.org

2 users in discussion

Andres L.: 1 post Andrus Adamchik: 1 post

People

Translate

site design / logo © 2022 Grokbase