Use custom dialects for HQL. Instead of using || create your own concat function. Then, in the SQL Server dialog box, add this to the constructor:
registerFunction("concat", new VarArgsSQLFunction(Hibernate.STRING, "", "+", ""));
You do not need to change the dialect of Oracle, because Oracle already has a concat function, so it just passes, but for other functions you may need to register new functions in both.
For SQL queries, since you dynamically create them, you can use base class methods such as super.addBitAndClause (leftSide, rightSide).
You can even switch to a dialect dynamically, although Hibernate did not simplify it by adding an interface:
Dialect d = ((SessionFactoryImpl)sessionFactory).getDialect()
source
share