This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 3817

Use native SQL.


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

Joined: Jan 17, 2008
Posts: 2274
    
  28

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
Group by desc in jpql
WA #1.....word association
append data to an existing column. - help
Constructor Expression