Registering a SQL function with JPA/Hibernate

I would like to know what's the best way to register a custom SQL function with JPA/Hibernate.

Do I have to go through extending the MysqlInnodb dialect or is there a better way?

Can anyone please provide code samples and pointers to relevant documentation?


Yes extending the dialect is a good way of registering custom SQL function.

Add something like this in your Dialect classes constructor.

registerFunction("current_timestamp", new NoArgSQLFunction(Hibernate.TIMESTAMP) );
registerFunction("date", new StandardSQLFunction(Hibernate.DATE) );

Look at the source code of one of the existing dialect classes.

Need Your Help

How to achieve unique auto-incremented id for rows across multiple tables?

mysql primary-key auto-increment

I've got several tables in a database, let's say they're called table1, table 2, etc.

mysql update one table with data from another

mysql sql

I am getting an issue with this update statement: