[jbpm-commits] JBoss JBPM SVN: r5035 - in jbpm3/branches/jbpm-3.2-soa/modules/core: src/main/java/org/jbpm/db/hibernate and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jun 12 14:46:50 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-06-12 14:46:50 -0400 (Fri, 12 Jun 2009)
New Revision: 5035

Modified:
   jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
Log:
JBPM-2094: Unindexed Foreign Keys cause deadlocks in oracle (REOPENED)
Exclude JBPM2094Test in Sybase profile - <exclude> configuration was wrong

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml	2009-06-12 14:47:43 UTC (rev 5034)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml	2009-06-12 18:46:50 UTC (rev 5035)
@@ -315,8 +315,10 @@
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
-              <!-- [JBPM-2094] Unindexed Foreign Keys cause deadlocks in oracle -->
-              <excludes>org/jbpm/jbpm2094/JBPM2094Test.java</excludes>
+              <excludes>
+                <!-- [JBPM-2094] Unindexed Foreign Keys cause deadlocks in oracle -->
+                <exclude>org/jbpm/jbpm2094/JBPM2094Test.java</exclude>
+              </excludes>
             </configuration>
           </plugin>
         </plugins>

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java	2009-06-12 14:47:43 UTC (rev 5034)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java	2009-06-12 18:46:50 UTC (rev 5035)
@@ -39,140 +39,123 @@
 import org.hibernate.util.StringHelper;
 
 /**
+ * Replacement for {@link org.hibernate.type.TextType} made to work around a <em>feature</em> in the
+ * jConnect driver when setting a text parameter to <code>null</code>. Specifically, the call:
+ * 
+ * <pre>
+ * PreparedStatement st;
+ * st.setNull(index, Types.CLOB);
+ * </pre>
+ * 
+ * throws an SQLException with SQL state "JZ0SL" and reason "Unsupported SQL type".
+ * 
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1818">JBPM-1818</a>
  * @author Alejandro Guizar
  */
-public class TextType implements EnhancedUserType, Serializable
-{
+public class TextType implements EnhancedUserType, Serializable {
 
   private transient Log log;
-  private static final boolean IS_VALUE_TRACING_ENABLED = LogFactory.getLog(StringHelper.qualifier(Type.class.getName())).isTraceEnabled();
+  private static final boolean IS_VALUE_TRACING_ENABLED = LogFactory.getLog(StringHelper.qualifier(Type.class.getName()))
+      .isTraceEnabled();
 
   private static final long serialVersionUID = 1L;
 
-  private Log log()
-  {
-    if (log == null)
-    {
+  private Log log() {
+    if (log == null) {
       log = LogFactory.getLog(getClass());
     }
     return log;
   }
 
-  public Object assemble(Serializable cached, Object owner) throws HibernateException
-  {
-    if (cached == null)
-    {
+  public Object assemble(Serializable cached, Object owner) throws HibernateException {
+    if (cached == null) {
       return null;
     }
-    else
-    {
+    else {
       return deepCopy(cached);
     }
   }
 
-  public Object deepCopy(Object value) throws HibernateException
-  {
+  public Object deepCopy(Object value) throws HibernateException {
     return value;
   }
 
-  public Serializable disassemble(Object value) throws HibernateException
-  {
-    if (value == null)
-    {
+  public Serializable disassemble(Object value) throws HibernateException {
+    if (value == null) {
       return null;
     }
-    else
-    {
-      return (Serializable)deepCopy(value);
+    else {
+      return (Serializable) deepCopy(value);
     }
   }
 
-  public boolean equals(Object x, Object y) throws HibernateException
-  {
+  public boolean equals(Object x, Object y) throws HibernateException {
     return EqualsHelper.equals(x, y);
   }
 
-  public int hashCode(Object x) throws HibernateException
-  {
+  public int hashCode(Object x) throws HibernateException {
     return x.hashCode();
   }
 
-  public boolean isMutable()
-  {
+  public boolean isMutable() {
     return false;
   }
 
-  public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
-  {
+  public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException,
+      SQLException {
     return nullSafeGet(rs, names[0]);
   }
 
-  public Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException
-  {
-    try
-    {
+  public Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException {
+    try {
       Object value = get(rs, name);
-      if (value == null)
-      {
-        if (IS_VALUE_TRACING_ENABLED)
-        {
+      if (value == null) {
+        if (IS_VALUE_TRACING_ENABLED) {
           log().trace("returning null as column: " + name);
         }
         return null;
       }
-      else
-      {
-        if (IS_VALUE_TRACING_ENABLED)
-        {
+      else {
+        if (IS_VALUE_TRACING_ENABLED) {
           log().trace("returning '" + toString(value) + "' as column: " + name);
         }
         return value;
       }
     }
-    catch (RuntimeException re)
-    {
+    catch (RuntimeException re) {
       log().info("could not read column value from result set: " + name + "; " + re.getMessage());
       throw re;
     }
-    catch (SQLException se)
-    {
+    catch (SQLException se) {
       log().info("could not read column value from result set: " + name + "; " + se.getMessage());
       throw se;
     }
   }
 
-  public Object get(ResultSet rs, String name) throws HibernateException, SQLException
-  {
+  public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
     // retrieve the value of the designated column in the current row of the
     // result set as a character reader
     Reader charReader = rs.getCharacterStream(name);
 
     // if the corresponding SQL value is NULL, the reader we got is NULL as well
-    if (charReader == null || rs.wasNull())
-      return null;
+    if (charReader == null || rs.wasNull()) return null;
 
     // Fetch Reader content up to the end - and put characters in a StringBuffer
     StringBuffer sbuf = new StringBuffer();
-    try
-    {
+    try {
       char[] cbuf = new char[1024];
-      for (int amountRead; (amountRead = charReader.read(cbuf)) != -1;)
-      {
+      for (int amountRead; (amountRead = charReader.read(cbuf)) != -1;) {
         sbuf.append(cbuf, 0, amountRead);
       }
     }
-    catch (IOException ioe)
-    {
+    catch (IOException ioe) {
       throw new HibernateException("IOException occurred reading text", ioe);
     }
-    finally
-    {
-      try
-      {
+    finally {
+      try {
         charReader.close();
       }
-      catch (IOException e)
-      {
+      catch (IOException e) {
         throw new HibernateException("IOException occurred closing stream", e);
       }
     }
@@ -181,100 +164,92 @@
     return sbuf.toString();
   }
 
-  public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
-  {
-    try
-    {
-      if (value == null)
-      {
-        if (IS_VALUE_TRACING_ENABLED)
-        {
+  public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException,
+      SQLException {
+    try {
+      if (value == null) {
+        if (IS_VALUE_TRACING_ENABLED) {
           log().trace("binding null to parameter: " + index);
         }
 
         setNull(st, index);
       }
-      else
-      {
-        if (IS_VALUE_TRACING_ENABLED)
-        {
+      else {
+        if (IS_VALUE_TRACING_ENABLED) {
           log().trace("binding '" + toString(value) + "' to parameter: " + index);
         }
 
         set(st, value, index);
       }
     }
-    catch (RuntimeException re)
-    {
-      log().info("could not bind value '" + nullSafeToString(value) + "' to parameter: " + index + "; " + re.getMessage());
+    catch (RuntimeException re) {
+      log().info("could not bind value '" +
+          nullSafeToString(value) +
+          "' to parameter: " +
+          index +
+          "; " +
+          re.getMessage());
       throw re;
     }
-    catch (SQLException se)
-    {
-      log().info("could not bind value '" + nullSafeToString(value) + "' to parameter: " + index + "; " + se.getMessage());
+    catch (SQLException se) {
+      log().info("could not bind value '" +
+          nullSafeToString(value) +
+          "' to parameter: " +
+          index +
+          "; " +
+          se.getMessage());
       throw se;
     }
   }
 
-  public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
-  {
-    String str = (String)value;
+  public void set(PreparedStatement st, Object value, int index) throws HibernateException,
+      SQLException {
+    String str = (String) value;
     st.setCharacterStream(index, new StringReader(str), str.length());
   }
 
-  public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException
-  {
+  public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException {
     // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with jConnect
     st.setCharacterStream(index, null, 0);
   }
 
-  public Object replace(Object original, Object target, Object owner) throws HibernateException
-  {
+  public Object replace(Object original, Object target, Object owner) throws HibernateException {
     return original;
   }
 
-  public Class returnedClass()
-  {
+  public Class returnedClass() {
     return String.class;
   }
 
-  public int[] sqlTypes()
-  {
+  public int[] sqlTypes() {
     return new int[] { sqlType() };
   }
 
-  public int sqlType()
-  {
+  public int sqlType() {
     return Types.CLOB;
   }
 
-  public String objectToSQLString(Object value)
-  {
-    return '\'' + (String)value + '\'';
+  public String objectToSQLString(Object value) {
+    return '\'' + (String) value + '\'';
   }
 
-  public Object fromXMLString(String xml)
-  {
+  public Object fromXMLString(String xml) {
     return xml == null || xml.length() == 0 ? null : fromStringValue(xml);
   }
 
-  public String toXMLString(Object value)
-  {
+  public String toXMLString(Object value) {
     return toString(value);
   }
 
-  public String nullSafeToString(Object value) throws HibernateException
-  {
+  public String nullSafeToString(Object value) throws HibernateException {
     return value == null ? null : toString(value);
   }
 
-  public String toString(Object val)
-  {
-    return (String)val;
+  public String toString(Object val) {
+    return (String) val;
   }
 
-  public Object fromStringValue(String xml)
-  {
+  public Object fromStringValue(String xml) {
     return xml;
   }
 }




More information about the jbpm-commits mailing list