I have CriteriaAPI query with some projections (Projections.SqlProjection). First parameter in Projections.SqlProjection method is sql string. I’d like to change the query to do it portable across databases. What should I do with sql string parameter in Projections.SqlProjection method? Should I re-write sql to hql?
I have CriteriaAPI query with some projections ( Projections.SqlProjection ). First parameter in Projections.SqlProjection
Share
If the provided sql is ANSI SQL, and the target databases support the used syntax, it is already portable. When database specific features are used, you need to rewrite it. It may be hard, because there is a reason why native SQL had been used. There is a chance that the original author just didn’t know that there is a nice solution within hibernate.