Re: Select by PK

From: Tore Halset (halse..vv.ntnu.no)
Date: Wed Jan 07 2004 - 07:11:46 EST

  • Next message: Jim Menard: "Re: Select by PK"

    On Jan 7, 2004, at 13:29, Leonardo Queiroz Antunes wrote:

    > how can we select an object by its pk value?

    I use something like this:

            public static Order getOrderByOrderId(DataContext dataContext, Integer
    orderId) {
                    Expression qual =
    ExpressionFactory.matchDbExp(Order.ORDER_ID_PK_COLUMN, orderId);
                    SelectQuery query = new SelectQuery(Order.class, qual);
                    List orders = dataContext.performQuery(query);
                    if (orders.size() == 1) {
                            return (Order) orders.get(0);
                    }
                    return null;
            }

      - Tore.



    This archive was generated by hypermail 2.0.0 : Wed Jan 07 2004 - 07:12:01 EST