• Post Reply Bookmark Topic Watch Topic
  • New Topic

alternate Floor function in JPA

 
manushree deepak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3953
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use native SQL.
 
Jayesh A Lalwani
Rancher
Posts: 2762
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you floor it in java?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
manushree deepak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,

SELECT FUNC('FLOOR', MAX(ctr1.version)) FROM version ctr1 WHERE ctr1.id = :id AND ctr1.name = :name
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!