File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes alternate Floor function in JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "alternate Floor function in JPA" Watch "alternate Floor function in JPA" New topic
Author

alternate Floor function in JPA

manushree deepak
Greenhorn

Joined: Feb 12, 2009
Posts: 9
Hi,

my JPQL is " SELECT FLOOR(MAX(ctr1.version)) FROM version ctr1 WHERE ctr1.id = ?1 AND ctr1.name = ?2 "

as i know floor function is not there in JPQL .Is there any alternative approach to get the FLOOR functionality.Please help me.


Thank you,
Kavitha
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Use native SQL.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2052
    
  22

Can't you floor it in java?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
If you are using EclipseLink you can use the FUNC keyword to call a specific database function.

Otherwise, use native SQL, or process it in Java.


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
manushree deepak
Greenhorn

Joined: Feb 12, 2009
Posts: 9
i am using EclipseLink ... is it correct ?

SELECT FUNC(FLOOR(MAX(ctr1.version))) FROM version ctr1 WHERE ctr1.id = ?1 AND ctr1.name = ?2
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
No,

SELECT FUNC('FLOOR', MAX(ctr1.version)) FROM version ctr1 WHERE ctr1.id = :id AND ctr1.name = :name
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: alternate Floor function in JPA
 
Similar Threads
JPQL Query Dout
Constructor Expression
Group by desc in jpql
append data to an existing column. - help
WA #1.....word association