hibernate - How do I calculate the anniversary date in JPQL -


i'm using jpa2

i have queried in ms access in following way

for example, find out anniversary in 2 years:

select dateadd(year, 2, initialdate) anniv 

or find out how many years have passed since initial date:

select datediff(year, initialdate, getdate()) yearspassed 

i'm not able find function in dateadd in jpql

could 1 please me getting similar effect in jpql

hibernate session provides dowork() method gives direct access java.sql.connection. can create , use java.sql.callablestatement execute function.

here oracledb function example:

session.dowork(new work() {   public void execute(connection connection) throws sqlexception {     callablestatement call = connection.preparecall("{ ? = call myschema.myfunc(?,?) }");     call.registeroutparameter( 1, types.integer ); // or whatever     call.setlong(2, id);     call.setlong(3, transid);     call.execute();     int result = call.getint(1); // propagate enclosing class   } }); 

or calculate within programm logic.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -