Migrating Hibernate3 to Hibernate5, Formatter class

91 views Asked by At

How can I edit this piece of code used with hibernate 3 in order to corresponds to hibernate 5.6.1 version.

I see that Formatter is now an interface with one single method. enter image description here

1

There are 1 answers

0
xerx593 On

For "basic SQL statements (DML + query)", please "try":

Formatter formatter = new org.hibernate.engine.jdbc.internal.BasicFormatterImpl();
formatter.format(query);

BasicFormatterImpl javadoc

For "DDL SQL statements", please:

Formatter formatter = org.hibernate.engine.jdbc.internal.DDLFormatterImpl.INSTANCE;
formatter.format(query);

DDLFormatterImpl javadoc

For "indent-/initialString" please consider a custom implementation, you can base on((/see source code of) the mentioned: