users@glassfish.java.net

Postgres, Toplink Essentials, and truncateDate function.

From: <glassfish_at_javadesktop.org>
Date: Thu, 11 Oct 2007 18:34:43 PDT

Toplink Essentials has an ExpressionBuilder subsystem, which is not part of the JPA, but used internally to create the EQL/SQL expressions.

We happen to use it directly within our code to build dynamic EQL expressions, once you get the hang of it, it's much nicer than building up Strings. Hibernate has an alternative, Criteria package I think.

Toplink has a truncateDate function that can be used to, well, truncate dates, say to knock off the hh:mm:ss of a timestamp, and leave only the Month, Day, Year.

However, as of v2, this is not supported for the Postgres platform. If you use it, it throws an exception because truncateDate is not an implemented operator.

In the persistence.xml file, you can specify your database platform as an implementing class name.

Since we needed the truncateDate functionality on our system, I created a subclass of Toplinks PostgresSQLPlatform, and added in the code to support truncateDate.

I filed an issue for it as a defect, and included the code in the issue.

https://glassfish.dev.java.net/issues/show_bug.cgi?id=3765

If anyone else needs this functionality, then feel free to reference that issue for a solution.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=239639