how do i implement support for the sql month( timestamp ) and week(timestamp) for JPA queries?

View: New views
2 Messages — Rating Filter:   Alert me  

how do i implement support for the sql month( timestamp ) and week(timestamp) for JPA queries?

by Gustav Trede-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

how do i implement support for the sql month( timestamp ) and week(timestamp)   for JPA queries?

regards
  gustav
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: how do i implement support for the sql month( timestamp ) and week(timestamp) for JPA queries?

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The JPA does not define such functions in JPQL, so EclipseLink does not currently support them.
See,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=219814

EclipseLink does have support for several related date functions and user defined functions through Expression queries.  You can create Expression queries using JpaEntityManager.createQuery(Expression, Class) or using a SessionCustomizer to add named ReadAllQuery's to the Session (and execute as normal JPA NamedQuery's).

EclipseLink does not have a month() function, but depending on your database platform you may be able to use,
- datePart(part)
- dateName(name)
- toChar(format)
or,
- getFunction(sqlFunction)


Gustav Trede-2 wrote:
Hello,

how do i implement support for the sql month( timestamp ) and
week(timestamp)   for JPA queries?

regards
  gustav