|
|
|
| Re: Equivalent of ROUND in criteria query in JPA 2 [message #550987 is a reply to message #550906] |
Wed, 04 August 2010 14:54  |
Chad Retz Messages: 6 Registered: July 2010 |
Junior Member |
|
|
Well, I figure it is already somewhat there with ExpressionOperator#round(), so I figure something along the following lines would work for JPA:
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T extends Number> Expression<T> round(EntityManager em,
Expression<T> value, int length) {
return new FunctionExpressionImpl(em.getMetamodel(), ClassConstants.NUMBER,
ExpressionOperator.round().expressionFor(((InternalSelection) value).
getCurrentNode(), length), Arrays.asList(value), "round");
}
...but I haven't tested it.
|
|
|
Powered by
FUDForum. Page generated in 0.01599 seconds