details: https://code.openbravo.com/erp/devel/pi/rev/12232bee10ef changeset: 34193:12232bee10ef user: Carlos Aristu <carlos.aristu <at> openbravo.com> date: Wed Jun 13 17:18:35 2018 +0200 summary: fixes issue 38749: InventoryCountProcess registers SQL functions in a non-standard way
Register in Hibernate the SQL functions required by the InventoryCountProcess class during the initialization of the DAL layer: - get_uuid: being already registered in the KernelSQLFunctionRegister - to_date: there is no need of explicitly registering it, it is already registered by the corresponding PostgreSQL and Oracle dialects - to_timestamp: being registered by default with the PostgreSQL but not with the Oracle dialect. So for PostgreSQL we are overriding the registry of this function. For this reason we are registering it in the same way as done by the PostgreSQL dialect. - now: the same as to_timestamp function diffstat: modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelSQLFunctionRegister.java | 5 +- src/org/openbravo/materialmgmt/InventoryCountProcess.java | 25 ---------- 2 files changed, 4 insertions(+), 26 deletions(-) diffs (72 lines): diff -r 6230cdf4f146 -r 12232bee10ef modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelSQLFunctionRegister.java --- a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelSQLFunctionRegister.java Tue Jun 12 12:08:11 2018 +0000 +++ b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelSQLFunctionRegister.java Wed Jun 13 17:18:35 2018 +0200 @@ -23,6 +23,7 @@ import javax.enterprise.context.ApplicationScoped; +import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.SQLFunction; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.type.StandardBasicTypes; @@ -46,7 +47,9 @@ StandardBasicTypes.STRING)); sqlFunctions.put("m_getjsondescription", new StandardSQLFunction("m_getjsondescription", StandardBasicTypes.STRING)); - sqlFunctions.put("now", new StandardSQLFunction("now", StandardBasicTypes.DATE)); + sqlFunctions.put("now", new NoArgSQLFunction("now", StandardBasicTypes.TIMESTAMP)); + sqlFunctions.put("to_timestamp", new StandardSQLFunction("to_timestamp", + StandardBasicTypes.TIMESTAMP)); return sqlFunctions; } } diff -r 6230cdf4f146 -r 12232bee10ef src/org/openbravo/materialmgmt/InventoryCountProcess.java --- a/src/org/openbravo/materialmgmt/InventoryCountProcess.java Tue Jun 12 12:08:11 2018 +0000 +++ b/src/org/openbravo/materialmgmt/InventoryCountProcess.java Wed Jun 13 17:18:35 2018 +0200 @@ -24,7 +24,6 @@ import java.util.Date; import java.util.Iterator; import java.util.List; -import java.util.Map; import javax.enterprise.inject.Any; import javax.enterprise.inject.Instance; @@ -35,14 +34,7 @@ import org.hibernate.Query; import org.hibernate.QueryTimeoutException; import org.hibernate.Session; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.function.SQLFunction; -import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.exception.GenericJDBCException; -import org.hibernate.impl.SessionFactoryImpl; -import org.hibernate.impl.SessionImpl; -import org.hibernate.type.DateType; -import org.hibernate.type.StringType; import org.openbravo.advpaymentmngt.utility.FIN_Utility; import org.openbravo.base.exception.OBException; import org.openbravo.dal.core.OBContext; @@ -174,23 +166,6 @@ msg.setTitle(OBMessageUtils.messageBD("Success")); runChecks(inventory); - // In case get_uuid is not already registered, it's registered now. - final Dialect dialect = ((SessionFactoryImpl) ((SessionImpl) OBDal.getInstance().getSession()) - .getSessionFactory()).getDialect(); - Map<String, SQLFunction> function = dialect.getFunctions(); - if (!function.containsKey("get_uuid")) { - dialect.getFunctions().put("get_uuid", new StandardSQLFunction("get_uuid", new StringType())); - } - if (!function.containsKey("now")) { - dialect.getFunctions().put("now", new StandardSQLFunction("now", new DateType())); - } - if (!function.containsKey("to_date")) { - dialect.getFunctions().put("to_date", new StandardSQLFunction("to_date", new DateType())); - } - if (!function.containsKey("to_timestamp")) { - dialect.getFunctions().put("to_timestamp", - new StandardSQLFunction("to_timestamp", new DateType())); - } StringBuffer insert = new StringBuffer(); insert.append("insert into " + MaterialTransaction.ENTITY_NAME + "("); insert.append(" id "); ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits