Author: alex.guizar(a)jboss.com
Date: 2008-12-24 15:45:37 -0500 (Wed, 24 Dec 2008)
New Revision: 3548
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
Log:
restrict text type workaround to sybase, because it breaks hsqldb
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
===================================================================
---
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2008-12-24
19:58:13 UTC (rev 3547)
+++
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2008-12-24
20:45:37 UTC (rev 3548)
@@ -33,10 +33,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
import org.hibernate.type.Type;
import org.hibernate.usertype.UserType;
import org.hibernate.util.EqualsHelper;
import org.hibernate.util.StringHelper;
+import org.jbpm.JbpmContext;
+import org.jbpm.persistence.db.DbPersistenceServiceFactory;
+import org.jbpm.svc.Services;
/**
* @author Alejandro Guizar
@@ -197,9 +201,21 @@
}
public void setNull(PreparedStatement st, int index) throws HibernateException,
SQLException {
- st.setCharacterStream(index, null, 0);
+ if (getHibernateDialect().indexOf("Sybase") == -1) {
+ st.setNull(index, sqlType());
+ }
+ else {
+ // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with
jConnect
+ st.setCharacterStream(index, null, 0);
+ }
}
+ private String getHibernateDialect() {
+ DbPersistenceServiceFactory factory = (DbPersistenceServiceFactory) JbpmContext
+ .getCurrentJbpmContext().getServiceFactory(Services.SERVICENAME_PERSISTENCE);
+ return factory.getConfiguration().getProperty(Environment.DIALECT);
+ }
+
public Object replace(Object original, Object target, Object owner) throws
HibernateException {
return original;
}
@@ -209,9 +225,13 @@
}
public int[] sqlTypes() {
- return new int[] { Types.CLOB };
+ return new int[] { sqlType() };
}
+ public int sqlType() {
+ return Types.CLOB;
+ }
+
public String nullSafeToString(Object value) throws HibernateException {
return value == null ? null : toString(value);
}
Show replies by date