Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Expression for all lineitems that where picked today

Hello,

I am struggling constructing my EL _expression_ for the following:
"Select the first lineitem that was picked today"

final ExpressionBuilder eb = new ExpressionBuilder();
eb.get("pickedAt").greaterThanEqual(eb.addDate("day", 0)).and(eb.lessThan(eb.addDate("day", 1)))
                        .minimum();
ReadObjectQuery query = new ReadObjectQuery(LegacyOrderPosition.class);
query.setSelectionCriteria(eb);
final Object first = JpaHelper.createQuery(query, em).getSingleResult();

But this will not return me the expected entity, but rather some random entity that does not even have the "pickedAt" member set (its null).

How would I compose that query and how could I use the database provided DATE() method rather than the to give the date from the client using "new Date()".

Regards,
Phil

Back to the top