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
Post a Comment