This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths 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 Head First Android 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: 3886
    
    5

Use native SQL.


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

Joined: Jan 17, 2008
Posts: 2631
    
  31

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
 
Don't get me started about those stupid light bulbs.
 
subject: alternate Floor function in JPA
 
It's not a secret anymore!