Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • 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: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use native SQL.
 
Jayesh A Lalwani
Rancher
Posts: 2756
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic