Advertisement
Guest User

JBPM 3.2.2 -> HB4 patch

a guest
Nov 7th, 2013
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 138.33 KB | None | 0 0
  1. Index: src/main/java/org/hibernate/util/JDBCExceptionReporter.java
  2. ===================================================================
  3. --- src/main/java/org/hibernate/util/JDBCExceptionReporter.java (revision 0)
  4. +++ src/main/java/org/hibernate/util/JDBCExceptionReporter.java (revision 75353)
  5. @@ -0,0 +1,103 @@
  6. +//$Id: JDBCExceptionReporter.java 10669 2006-10-31 21:24:28Z epbernard $
  7. +package org.hibernate.util;
  8. +
  9. +import java.sql.Connection;
  10. +import java.sql.SQLException;
  11. +import java.sql.SQLWarning;
  12. +
  13. +import org.apache.commons.logging.Log;
  14. +import org.apache.commons.logging.LogFactory;
  15. +
  16. +public final class JDBCExceptionReporter {
  17. +
  18. +   public static final Log log = LogFactory.getLog(JDBCExceptionReporter.class);
  19. +   public static final String DEFAULT_EXCEPTION_MSG = "SQL Exception";
  20. +   public static final String DEFAULT_WARNING_MSG = "SQL Warning";
  21. +
  22. +   private JDBCExceptionReporter() {}
  23. +  
  24. +   public static void logAndClearWarnings(Connection connection) {
  25. +       if ( log.isWarnEnabled() ) {
  26. +           try {
  27. +               logWarnings( connection.getWarnings() );
  28. +           }
  29. +           catch (SQLException sqle) {
  30. +               //workaround for WebLogic
  31. +               log.debug("could not log warnings", sqle);
  32. +           }
  33. +       }
  34. +       try {
  35. +           //Sybase fail if we don't do that, sigh...
  36. +           connection.clearWarnings();
  37. +       }
  38. +       catch (SQLException sqle) {
  39. +           log.debug("could not clear warnings", sqle);
  40. +       }
  41. +   }
  42. +
  43. +   public static void logWarnings(SQLWarning warning) {
  44. +       logWarnings(warning, null);
  45. +   }
  46. +
  47. +   public static void logWarnings(SQLWarning warning, String message) {
  48. +       if ( log.isWarnEnabled() ) {
  49. +           if ( log.isDebugEnabled() && warning != null ) {
  50. +               message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG;
  51. +               log.debug( message, warning );
  52. +           }
  53. +           while (warning != null) {
  54. +               StringBuffer buf = new StringBuffer(30)
  55. +                       .append( "SQL Warning: ")
  56. +                       .append( warning.getErrorCode() )
  57. +                       .append( ", SQLState: ")
  58. +                       .append( warning.getSQLState() );
  59. +               log.warn( buf.toString() );
  60. +               log.warn( warning.getMessage() );
  61. +               warning = warning.getNextWarning();
  62. +           }
  63. +       }
  64. +   }
  65. +
  66. +   public static void logExceptions(SQLException ex) {
  67. +       logExceptions(ex, null);
  68. +   }
  69. +
  70. +   public static void logExceptions(SQLException ex, String message) {
  71. +       if ( log.isErrorEnabled() ) {
  72. +           if ( log.isDebugEnabled() ) {
  73. +               message = StringHelper.isNotEmpty(message) ? message : DEFAULT_EXCEPTION_MSG;
  74. +               log.debug( message, ex );
  75. +           }
  76. +           while (ex != null) {
  77. +               StringBuffer buf = new StringBuffer(30)
  78. +                       .append( "SQL Error: " )
  79. +                       .append( ex.getErrorCode() )
  80. +                       .append( ", SQLState: " )
  81. +                       .append( ex.getSQLState() );
  82. +               log.warn( buf.toString() );
  83. +               log.error( ex.getMessage() );
  84. +               ex = ex.getNextException();
  85. +           }
  86. +       }
  87. +   }
  88. +
  89. +// public static JDBCException newJDBCException(String string, SQLException root, String sql) {
  90. +//     string = string + " [" + sql + ']';
  91. +//     log.error(string, root);
  92. +//     logExceptions(root);
  93. +//     return new JDBCException(string, root, sql);
  94. +// }
  95. +//
  96. +// public static JDBCException newJDBCException(String string, SQLException root) {
  97. +//     log.error(string, root);
  98. +//     logExceptions(root);
  99. +//     return new JDBCException(string, root);
  100. +// }
  101. +
  102. +}
  103. +
  104. +
  105. +
  106. +
  107. +
  108. +
  109.  
  110. Property changes on: src\main\java\org\hibernate\util\JDBCExceptionReporter.java
  111. ___________________________________________________________________
  112. Added: svn:mime-type
  113.    + text/plain
  114.  
  115. Index: src/main/java/org/hibernate/util/StringHelper.java
  116. ===================================================================
  117. --- src/main/java/org/hibernate/util/StringHelper.java  (revision 0)
  118. +++ src/main/java/org/hibernate/util/StringHelper.java  (revision 75353)
  119. @@ -0,0 +1,662 @@
  120. +/*
  121. + * Hibernate, Relational Persistence for Idiomatic Java
  122. + *
  123. + * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
  124. + * indicated by the @author tags or express copyright attribution
  125. + * statements applied by the authors.  All third-party contributions are
  126. + * distributed under license by Red Hat Middleware LLC.
  127. + *
  128. + * This copyrighted material is made available to anyone wishing to use, modify,
  129. + * copy, or redistribute it subject to the terms and conditions of the GNU
  130. + * Lesser General Public License, as published by the Free Software Foundation.
  131. + *
  132. + * This program is distributed in the hope that it will be useful,
  133. + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  134. + * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
  135. + * for more details.
  136. + *
  137. + * You should have received a copy of the GNU Lesser General Public License
  138. + * along with this distribution; if not, write to:
  139. + * Free Software Foundation, Inc.
  140. + * 51 Franklin Street, Fifth Floor
  141. + * Boston, MA  02110-1301  USA
  142. + *
  143. + */
  144. +package org.hibernate.util;
  145. +
  146. +import java.util.Iterator;
  147. +import java.util.StringTokenizer;
  148. +import java.util.ArrayList;
  149. +import java.util.Arrays;
  150. +import java.util.regex.Pattern;
  151. +
  152. +import org.hibernate.dialect.Dialect;
  153. +
  154. +public final class StringHelper {
  155. +
  156. +   private static final int ALIAS_TRUNCATE_LENGTH = 10;
  157. +   public static final String WHITESPACE = " \n\r\f\t";
  158. +
  159. +   private StringHelper() { /* static methods only - hide constructor */
  160. +   }
  161. +  
  162. +   /*public static boolean containsDigits(String string) {
  163. +       for ( int i=0; i<string.length(); i++ ) {
  164. +           if ( Character.isDigit( string.charAt(i) ) ) return true;
  165. +       }
  166. +       return false;
  167. +   }*/
  168. +
  169. +   public static int lastIndexOfLetter(String string) {
  170. +       for ( int i=0; i<string.length(); i++ ) {
  171. +           char character = string.charAt(i);
  172. +           if ( !Character.isLetter(character) /*&& !('_'==character)*/ ) return i-1;
  173. +       }
  174. +       return string.length()-1;
  175. +   }
  176. +
  177. +   public static String join(String seperator, String[] strings) {
  178. +       int length = strings.length;
  179. +       if ( length == 0 ) return "";
  180. +       StringBuffer buf = new StringBuffer( length * strings[0].length() )
  181. +               .append( strings[0] );
  182. +       for ( int i = 1; i < length; i++ ) {
  183. +           buf.append( seperator ).append( strings[i] );
  184. +       }
  185. +       return buf.toString();
  186. +   }
  187. +
  188. +   public static String join(String seperator, Iterator objects) {
  189. +       StringBuffer buf = new StringBuffer();
  190. +       if ( objects.hasNext() ) buf.append( objects.next() );
  191. +       while ( objects.hasNext() ) {
  192. +           buf.append( seperator ).append( objects.next() );
  193. +       }
  194. +       return buf.toString();
  195. +   }
  196. +
  197. +   public static String[] add(String[] x, String sep, String[] y) {
  198. +       String[] result = new String[x.length];
  199. +       for ( int i = 0; i < x.length; i++ ) {
  200. +           result[i] = x[i] + sep + y[i];
  201. +       }
  202. +       return result;
  203. +   }
  204. +
  205. +   public static String repeat(String string, int times) {
  206. +       StringBuffer buf = new StringBuffer( string.length() * times );
  207. +       for ( int i = 0; i < times; i++ ) buf.append( string );
  208. +       return buf.toString();
  209. +   }
  210. +
  211. +   public static String repeat(char character, int times) {
  212. +       char[] buffer = new char[times];
  213. +       Arrays.fill( buffer, character );
  214. +       return new String( buffer );
  215. +   }
  216. +
  217. +
  218. +   public static String replace(String template, String placeholder, String replacement) {
  219. +       return replace( template, placeholder, replacement, false );
  220. +   }
  221. +
  222. +   public static String[] replace(String templates[], String placeholder, String replacement) {
  223. +       String[] result = new String[templates.length];
  224. +       for ( int i =0; i<templates.length; i++ ) {
  225. +           result[i] = replace( templates[i], placeholder, replacement );
  226. +       }
  227. +       return result;
  228. +   }
  229. +
  230. +   public static String replace(String template, String placeholder, String replacement, boolean wholeWords) {
  231. +       return replace( template, placeholder, replacement, wholeWords, false );
  232. +   }
  233. +
  234. +   public static String replace(String template,
  235. +                                String placeholder,
  236. +                                String replacement,
  237. +                                boolean wholeWords,
  238. +                                boolean encloseInParensIfNecessary) {
  239. +       if ( template == null ) {
  240. +           return template;
  241. +       }
  242. +       int loc = template.indexOf( placeholder );
  243. +       if ( loc < 0 ) {
  244. +           return template;
  245. +       }
  246. +       else {
  247. +           String beforePlaceholder = template.substring( 0, loc );
  248. +           String afterPlaceholder = template.substring( loc + placeholder.length() );
  249. +           return replace( beforePlaceholder, afterPlaceholder, placeholder, replacement, wholeWords, encloseInParensIfNecessary );
  250. +       }
  251. +   }
  252. +
  253. +
  254. +   public static String replace(String beforePlaceholder,
  255. +                                String afterPlaceholder,
  256. +                                String placeholder,
  257. +                                String replacement,
  258. +                                boolean wholeWords,
  259. +                                boolean encloseInParensIfNecessary) {
  260. +       final boolean actuallyReplace =
  261. +               ! wholeWords ||
  262. +               afterPlaceholder.length() == 0 ||
  263. +               ! Character.isJavaIdentifierPart( afterPlaceholder.charAt( 0 ) );
  264. +       boolean encloseInParens =
  265. +               actuallyReplace &&
  266. +               encloseInParensIfNecessary &&
  267. +               ! ( getLastNonWhitespaceCharacter( beforePlaceholder ) == '(' ) &&
  268. +               ! ( getFirstNonWhitespaceCharacter( afterPlaceholder ) == ')' );       
  269. +       StringBuilder buf = new StringBuilder( beforePlaceholder );
  270. +       if ( encloseInParens ) {
  271. +           buf.append( '(' );
  272. +       }
  273. +       buf.append( actuallyReplace ? replacement : placeholder );
  274. +       if ( encloseInParens ) {
  275. +           buf.append( ')' );
  276. +       }
  277. +       buf.append(
  278. +               replace(
  279. +                       afterPlaceholder,
  280. +                       placeholder,
  281. +                       replacement,
  282. +                       wholeWords,
  283. +                       encloseInParensIfNecessary
  284. +               )
  285. +       );
  286. +       return buf.toString();
  287. +   }
  288. +
  289. +   public static char getLastNonWhitespaceCharacter(String str) {
  290. +       if ( str != null && str.length() > 0 ) {
  291. +           for ( int i = str.length() - 1 ; i >= 0 ; i-- ) {
  292. +               char ch = str.charAt( i );
  293. +               if ( ! Character.isWhitespace( ch ) ) {
  294. +                   return ch;
  295. +               }
  296. +           }
  297. +       }
  298. +       return '\0';
  299. +   }
  300. +
  301. +   public static char getFirstNonWhitespaceCharacter(String str) {
  302. +       if ( str != null && str.length() > 0 ) {
  303. +           for ( int i = 0 ; i < str.length() ; i++ ) {
  304. +               char ch = str.charAt( i );
  305. +               if ( ! Character.isWhitespace( ch ) ) {
  306. +                   return ch;
  307. +               }
  308. +           }
  309. +       }
  310. +       return '\0';
  311. +   }
  312. +
  313. +   public static String replaceOnce(String template, String placeholder, String replacement) {
  314. +       if ( template == null ) {
  315. +           return template; // returnign null!
  316. +       }
  317. +        int loc = template.indexOf( placeholder );
  318. +       if ( loc < 0 ) {
  319. +           return template;
  320. +       }
  321. +       else {
  322. +           return new StringBuffer( template.substring( 0, loc ) )
  323. +                   .append( replacement )
  324. +                   .append( template.substring( loc + placeholder.length() ) )
  325. +                   .toString();
  326. +       }
  327. +   }
  328. +
  329. +
  330. +   public static String[] split(String seperators, String list) {
  331. +       return split( seperators, list, false );
  332. +   }
  333. +
  334. +   public static String[] split(String seperators, String list, boolean include) {
  335. +       StringTokenizer tokens = new StringTokenizer( list, seperators, include );
  336. +       String[] result = new String[ tokens.countTokens() ];
  337. +       int i = 0;
  338. +       while ( tokens.hasMoreTokens() ) {
  339. +           result[i++] = tokens.nextToken();
  340. +       }
  341. +       return result;
  342. +   }
  343. +
  344. +   public static String unqualify(String qualifiedName) {
  345. +       int loc = qualifiedName.lastIndexOf(".");
  346. +       return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( qualifiedName.lastIndexOf(".") + 1 );
  347. +   }
  348. +
  349. +   public static String qualifier(String qualifiedName) {
  350. +       int loc = qualifiedName.lastIndexOf(".");
  351. +       return ( loc < 0 ) ? "" : qualifiedName.substring( 0, loc );
  352. +   }
  353. +
  354. +   /**
  355. +    * Collapses a name.  Mainly intended for use with classnames, where an example might serve best to explain.
  356. +    * Imagine you have a class named <samp>'org.hibernate.util.StringHelper'</samp>; calling collapse on that
  357. +    * classname will result in <samp>'o.h.u.StringHelper'<samp>.
  358. +    *
  359. +    * @param name The name to collapse.
  360. +    * @return The collapsed name.
  361. +    */
  362. +   public static String collapse(String name) {
  363. +       if ( name == null ) {
  364. +           return null;
  365. +       }
  366. +       int breakPoint = name.lastIndexOf( '.' );
  367. +       if ( breakPoint < 0 ) {
  368. +           return name;
  369. +       }
  370. +       return collapseQualifier( name.substring( 0, breakPoint ), true ) + name.substring( breakPoint ); // includes last '.'
  371. +   }
  372. +
  373. +   /**
  374. +    * Given a qualifier, collapse it.
  375. +    *
  376. +    * @param qualifier The qualifier to collapse.
  377. +    * @param includeDots Should we include the dots in the collapsed form?
  378. +    *
  379. +    * @return The collapsed form.
  380. +    */
  381. +   public static String collapseQualifier(String qualifier, boolean includeDots) {
  382. +       StringTokenizer tokenizer = new StringTokenizer( qualifier, "." );
  383. +       String collapsed = Character.toString( tokenizer.nextToken().charAt( 0 ) );
  384. +       while ( tokenizer.hasMoreTokens() ) {
  385. +           if ( includeDots ) {
  386. +               collapsed += '.';
  387. +           }
  388. +           collapsed += tokenizer.nextToken().charAt( 0 );
  389. +       }
  390. +       return collapsed;
  391. +   }
  392. +
  393. +   /**
  394. +    * Partially unqualifies a qualified name.  For example, with a base of 'org.hibernate' the name
  395. +    * 'org.hibernate.util.StringHelper' would become 'util.StringHelper'.
  396. +    *
  397. +    * @param name The (potentially) qualified name.
  398. +    * @param qualifierBase The qualifier base.
  399. +    *
  400. +    * @return The name itself, or the partially unqualified form if it begins with the qualifier base.
  401. +    */
  402. +   public static String partiallyUnqualify(String name, String qualifierBase) {
  403. +       if ( name == null || ! name.startsWith( qualifierBase ) ) {
  404. +           return name;
  405. +       }
  406. +       return name.substring( qualifierBase.length() + 1 ); // +1 to start after the following '.'
  407. +   }
  408. +
  409. +   /**
  410. +    * Cross between {@link #collapse} and {@link #partiallyUnqualify}.  Functions much like {@link #collapse}
  411. +    * except that only the qualifierBase is collapsed.  For example, with a base of 'org.hibernate' the name
  412. +    * 'org.hibernate.util.StringHelper' would become 'o.h.util.StringHelper'.
  413. +    *
  414. +    * @param name The (potentially) qualified name.
  415. +    * @param qualifierBase The qualifier base.
  416. +    *
  417. +    * @return The name itself if it does not begin with the qualifierBase, or the properly collapsed form otherwise.
  418. +    */
  419. +   public static String collapseQualifierBase(String name, String qualifierBase) {
  420. +       if ( name == null || ! name.startsWith( qualifierBase ) ) {
  421. +           return collapse( name );
  422. +       }
  423. +       return collapseQualifier( qualifierBase, true ) + name.substring( qualifierBase.length() );
  424. +   }
  425. +
  426. +   public static String[] suffix(String[] columns, String suffix) {
  427. +       if ( suffix == null ) return columns;
  428. +       String[] qualified = new String[columns.length];
  429. +       for ( int i = 0; i < columns.length; i++ ) {
  430. +           qualified[i] = suffix( columns[i], suffix );
  431. +       }
  432. +       return qualified;
  433. +   }
  434. +
  435. +   private static String suffix(String name, String suffix) {
  436. +       return ( suffix == null ) ? name : name + suffix;
  437. +   }
  438. +
  439. +   public static String root(String qualifiedName) {
  440. +       int loc = qualifiedName.indexOf( "." );
  441. +       return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( 0, loc );
  442. +   }
  443. +
  444. +   public static String unroot(String qualifiedName) {
  445. +       int loc = qualifiedName.indexOf( "." );
  446. +       return ( loc < 0 ) ? qualifiedName : qualifiedName.substring( loc+1, qualifiedName.length() );
  447. +   }
  448. +
  449. +   public static boolean booleanValue(String tfString) {
  450. +       String trimmed = tfString.trim().toLowerCase();
  451. +       return trimmed.equals( "true" ) || trimmed.equals( "t" );
  452. +   }
  453. +
  454. +   public static String toString(Object[] array) {
  455. +       int len = array.length;
  456. +       if ( len == 0 ) return "";
  457. +       StringBuffer buf = new StringBuffer( len * 12 );
  458. +       for ( int i = 0; i < len - 1; i++ ) {
  459. +           buf.append( array[i] ).append(", ");
  460. +       }
  461. +       return buf.append( array[len - 1] ).toString();
  462. +   }
  463. +
  464. +   public static String[] multiply(String string, Iterator placeholders, Iterator replacements) {
  465. +       String[] result = new String[]{string};
  466. +       while ( placeholders.hasNext() ) {
  467. +           result = multiply( result, ( String ) placeholders.next(), ( String[] ) replacements.next() );
  468. +       }
  469. +       return result;
  470. +   }
  471. +
  472. +   private static String[] multiply(String[] strings, String placeholder, String[] replacements) {
  473. +       String[] results = new String[replacements.length * strings.length];
  474. +       int n = 0;
  475. +       for ( int i = 0; i < replacements.length; i++ ) {
  476. +           for ( int j = 0; j < strings.length; j++ ) {
  477. +               results[n++] = replaceOnce( strings[j], placeholder, replacements[i] );
  478. +           }
  479. +       }
  480. +       return results;
  481. +   }
  482. +
  483. +   public static int countUnquoted(String string, char character) {
  484. +       if ( '\'' == character ) {
  485. +           throw new IllegalArgumentException( "Unquoted count of quotes is invalid" );
  486. +       }
  487. +       if (string == null)
  488. +           return 0;
  489. +       // Impl note: takes advantage of the fact that an escpaed single quote
  490. +       // embedded within a quote-block can really be handled as two seperate
  491. +       // quote-blocks for the purposes of this method...
  492. +       int count = 0;
  493. +       int stringLength = string.length();
  494. +       boolean inQuote = false;
  495. +       for ( int indx = 0; indx < stringLength; indx++ ) {
  496. +           char c = string.charAt( indx );
  497. +           if ( inQuote ) {
  498. +               if ( '\'' == c ) {
  499. +                   inQuote = false;
  500. +               }
  501. +           }
  502. +           else if ( '\'' == c ) {
  503. +               inQuote = true;
  504. +           }
  505. +           else if ( c == character ) {
  506. +               count++;
  507. +           }
  508. +       }
  509. +       return count;
  510. +   }
  511. +
  512. +   public static int[] locateUnquoted(String string, char character) {
  513. +       if ( '\'' == character ) {
  514. +           throw new IllegalArgumentException( "Unquoted count of quotes is invalid" );
  515. +       }
  516. +       if (string == null) {
  517. +           return new int[0];
  518. +       }
  519. +
  520. +       ArrayList locations = new ArrayList( 20 );
  521. +
  522. +       // Impl note: takes advantage of the fact that an escpaed single quote
  523. +       // embedded within a quote-block can really be handled as two seperate
  524. +       // quote-blocks for the purposes of this method...
  525. +       int stringLength = string.length();
  526. +       boolean inQuote = false;
  527. +       for ( int indx = 0; indx < stringLength; indx++ ) {
  528. +           char c = string.charAt( indx );
  529. +           if ( inQuote ) {
  530. +               if ( '\'' == c ) {
  531. +                   inQuote = false;
  532. +               }
  533. +           }
  534. +           else if ( '\'' == c ) {
  535. +               inQuote = true;
  536. +           }
  537. +           else if ( c == character ) {
  538. +               locations.add( new Integer( indx ) );
  539. +           }
  540. +       }
  541. +       return ArrayHelper.toIntArray( locations );
  542. +   }
  543. +
  544. +   public static boolean isNotEmpty(String string) {
  545. +       return string != null && string.length() > 0;
  546. +   }
  547. +
  548. +   public static boolean isEmpty(String string) {
  549. +       return string == null || string.length() == 0;
  550. +   }
  551. +
  552. +   public static String qualify(String prefix, String name) {
  553. +       if ( name == null || prefix == null ) {
  554. +           throw new NullPointerException();
  555. +       }
  556. +       return new StringBuffer( prefix.length() + name.length() + 1 )
  557. +               .append(prefix)
  558. +               .append('.')
  559. +               .append(name)
  560. +               .toString();
  561. +   }
  562. +
  563. +   public static String[] qualify(String prefix, String[] names) {
  564. +       if ( prefix == null ) return names;
  565. +       int len = names.length;
  566. +       String[] qualified = new String[len];
  567. +       for ( int i = 0; i < len; i++ ) {
  568. +           qualified[i] = qualify( prefix, names[i] );
  569. +       }
  570. +       return qualified;
  571. +   }
  572. +
  573. +   public static int firstIndexOfChar(String sqlString, String string, int startindex) {
  574. +       int matchAt = -1;
  575. +       for ( int i = 0; i < string.length(); i++ ) {
  576. +           int curMatch = sqlString.indexOf( string.charAt( i ), startindex );
  577. +           if ( curMatch >= 0 ) {
  578. +               if ( matchAt == -1 ) { // first time we find match!
  579. +                   matchAt = curMatch;
  580. +               }
  581. +               else {
  582. +                   matchAt = Math.min( matchAt, curMatch );
  583. +               }
  584. +           }
  585. +       }
  586. +       return matchAt;
  587. +   }
  588. +
  589. +   public static String truncate(String string, int length) {
  590. +       if ( string.length() <= length ) {
  591. +           return string;
  592. +       }
  593. +       else {
  594. +           return string.substring( 0, length );
  595. +       }
  596. +   }
  597. +
  598. +   public static String generateAlias(String description) {
  599. +       return generateAliasRoot(description) + '_';
  600. +   }
  601. +
  602. +   /**
  603. +    * Generate a nice alias for the given class name or collection role name and unique integer. Subclasses of
  604. +    * Loader do <em>not</em> have to use aliases of this form.
  605. +    *
  606. +    * @param description The base name (usually an entity-name or collection-role)
  607. +    * @param unique A uniquing value
  608. +    *
  609. +    * @return an alias of the form <samp>foo1_</samp>
  610. +    */
  611. +   public static String generateAlias(String description, int unique) {
  612. +       return generateAliasRoot(description) +
  613. +           Integer.toString(unique) +
  614. +           '_';
  615. +   }
  616. +
  617. +   /**
  618. +    * Generates a root alias by truncating the "root name" defined by
  619. +    * the incoming decription and removing/modifying any non-valid
  620. +    * alias characters.
  621. +    *
  622. +    * @param description The root name from which to generate a root alias.
  623. +    * @return The generated root alias.
  624. +    */
  625. +   private static String generateAliasRoot(String description) {
  626. +       String result = truncate( unqualifyEntityName(description), ALIAS_TRUNCATE_LENGTH )
  627. +               .toLowerCase()
  628. +               .replace( '/', '_' ) // entityNames may now include slashes for the representations
  629. +               .replace( '$', '_' ); //classname may be an inner class
  630. +       result = cleanAlias( result );
  631. +       if ( Character.isDigit( result.charAt(result.length()-1) ) ) {
  632. +           return result + "x"; //ick!
  633. +       }
  634. +       else {
  635. +           return result;
  636. +       }
  637. +   }
  638. +
  639. +   /**
  640. +    * Clean the generated alias by removing any non-alpha characters from the
  641. +    * beginning.
  642. +    *
  643. +    * @param alias The generated alias to be cleaned.
  644. +    * @return The cleaned alias, stripped of any leading non-alpha characters.
  645. +    */
  646. +   private static String cleanAlias(String alias) {
  647. +       char[] chars = alias.toCharArray();
  648. +       // short cut check...
  649. +       if ( !Character.isLetter( chars[0] ) ) {
  650. +           for ( int i = 1; i < chars.length; i++ ) {
  651. +               // as soon as we encounter our first letter, return the substring
  652. +               // from that position
  653. +               if ( Character.isLetter( chars[i] ) ) {
  654. +                   return alias.substring( i );
  655. +               }
  656. +           }
  657. +       }
  658. +       return alias;
  659. +   }
  660. +
  661. +   public static String unqualifyEntityName(String entityName) {
  662. +       String result = unqualify(entityName);
  663. +       int slashPos = result.indexOf( '/' );
  664. +       if ( slashPos > 0 ) {
  665. +           result = result.substring( 0, slashPos - 1 );
  666. +       }
  667. +       return result;
  668. +   }
  669. +  
  670. +   public static String toUpperCase(String str) {
  671. +       return str==null ? null : str.toUpperCase();
  672. +   }
  673. +  
  674. +   public static String toLowerCase(String str) {
  675. +       return str==null ? null : str.toLowerCase();
  676. +   }
  677. +
  678. +   public static String moveAndToBeginning(String filter) {
  679. +       if ( filter.trim().length()>0 ){
  680. +           filter += " and ";
  681. +           if ( filter.startsWith(" and ") ) filter = filter.substring(4);
  682. +       }
  683. +       return filter;
  684. +   }
  685. +
  686. +   /**
  687. +    * Determine if the given string is quoted (wrapped by '`' characters at beginning and end).
  688. +    *
  689. +    * @param name The name to check.
  690. +    * @return True if the given string starts and ends with '`'; false otherwise.
  691. +    */
  692. +   public static boolean isQuoted(String name) {
  693. +       return name != null && name.length() != 0 && name.charAt( 0 ) == '`' && name.charAt( name.length() - 1 ) == '`';
  694. +   }
  695. +
  696. +   /**
  697. +    * Return a representation of the given name ensuring quoting (wrapped with '`' characters).  If already wrapped
  698. +    * return name.
  699. +    *
  700. +    * @param name The name to quote.
  701. +    * @return The quoted version.
  702. +    */
  703. +   public static String quote(String name) {
  704. +       if ( name == null || name.length() == 0 || isQuoted( name ) ) {
  705. +           return name;
  706. +       }
  707. +       else {
  708. +           return new StringBuffer( name.length() + 2 ).append('`').append( name ).append( '`' ).toString();
  709. +       }
  710. +   }
  711. +
  712. +   /**
  713. +    * Return the unquoted version of name (stripping the start and end '`' characters if present).
  714. +    *
  715. +    * @param name The name to be unquoted.
  716. +    * @return The unquoted version.
  717. +    */
  718. +   public static String unquote(String name) {
  719. +       if ( isQuoted( name ) ) {
  720. +           return name.substring( 1, name.length() - 1 );
  721. +       }
  722. +       else {
  723. +           return name;
  724. +       }
  725. +   }
  726. +
  727. +   /**
  728. +    * Determine if the given name is quoted.  It is considered quoted if either:
  729. +    * <ol>
  730. +    * <li>starts AND ends with backticks (`)</li>
  731. +    * <li>starts with dialect-specified {@link org.hibernate.dialect.Dialect#openQuote() open-quote}
  732. +    *      AND ends with dialect-specified {@link org.hibernate.dialect.Dialect#closeQuote() close-quote}</li>
  733. +    * </ol>
  734. +    *
  735. +    * @param name The name to check
  736. +    * @param dialect The dialect (to determine the "real" quoting chars).
  737. +    *
  738. +    * @return True if quoted, false otherwise
  739. +    */
  740. +   public static boolean isQuoted(String name, Dialect dialect) {
  741. +       return name != null && name.length() != 0
  742. +               && ( name.charAt( 0 ) == '`' && name.charAt( name.length() - 1 ) == '`'
  743. +               || name.charAt( 0 ) == dialect.openQuote() && name.charAt( name.length() - 1 ) == dialect.closeQuote() );
  744. +   }
  745. +
  746. +   /**
  747. +    * Return the unquoted version of name stripping the start and end quote characters.
  748. +    *
  749. +    * @param name The name to be unquoted.
  750. +    * @param dialect The dialect (to determine the "real" quoting chars).
  751. +    *
  752. +    * @return The unquoted version.
  753. +    */
  754. +   public static String unquote(String name, Dialect dialect) {
  755. +       if ( isQuoted( name, dialect ) ) {
  756. +           return name.substring( 1, name.length() - 1 );
  757. +       }
  758. +       else {
  759. +           return name;
  760. +       }
  761. +   }
  762. +
  763. +   /**
  764. +    * Return the unquoted version of name stripping the start and end quote characters.
  765. +    *
  766. +    * @param names The names to be unquoted.
  767. +    * @param dialect The dialect (to determine the "real" quoting chars).
  768. +    *
  769. +    * @return The unquoted versions.
  770. +    */
  771. +   public static String[] unquote(String[] names, Dialect dialect) {
  772. +       if ( names == null ) {
  773. +           return null;
  774. +       }
  775. +       String[] unquoted = new String[ names.length ];
  776. +       for ( int i = 0; i < names.length; i++ ) {
  777. +           unquoted[i] = unquote( names[i], dialect );
  778. +       }
  779. +       return unquoted;
  780. +   }
  781. +}
  782.  
  783. Property changes on: src\main\java\org\hibernate\util\StringHelper.java
  784. ___________________________________________________________________
  785. Added: svn:mime-type
  786.    + text/plain
  787.  
  788. Index: src/main/java/org/hibernate/util/ArrayHelper.java
  789. ===================================================================
  790. --- src/main/java/org/hibernate/util/ArrayHelper.java   (revision 0)
  791. +++ src/main/java/org/hibernate/util/ArrayHelper.java   (revision 75353)
  792. @@ -0,0 +1,372 @@
  793. +/*
  794. + * Hibernate, Relational Persistence for Idiomatic Java
  795. + *
  796. + * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
  797. + * indicated by the @author tags or express copyright attribution
  798. + * statements applied by the authors.  All third-party contributions are
  799. + * distributed under license by Red Hat Middleware LLC.
  800. + *
  801. + * This copyrighted material is made available to anyone wishing to use, modify,
  802. + * copy, or redistribute it subject to the terms and conditions of the GNU
  803. + * Lesser General Public License, as published by the Free Software Foundation.
  804. + *
  805. + * This program is distributed in the hope that it will be useful,
  806. + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  807. + * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
  808. + * for more details.
  809. + *
  810. + * You should have received a copy of the GNU Lesser General Public License
  811. + * along with this distribution; if not, write to:
  812. + * Free Software Foundation, Inc.
  813. + * 51 Franklin Street, Fifth Floor
  814. + * Boston, MA  02110-1301  USA
  815. + *
  816. + */
  817. +package org.hibernate.util;
  818. +
  819. +import java.lang.reflect.Array;
  820. +import java.util.ArrayList;
  821. +import java.util.Arrays;
  822. +import java.util.Collection;
  823. +import java.util.Iterator;
  824. +import java.util.List;
  825. +
  826. +import org.hibernate.LockMode;
  827. +import org.hibernate.LockOptions;
  828. +import org.hibernate.type.Type;
  829. +
  830. +public final class ArrayHelper {
  831. +  
  832. +   /*public static boolean contains(Object[] array, Object object) {
  833. +       for ( int i=0; i<array.length; i++ ) {
  834. +           if ( array[i].equals(object) ) return true;
  835. +       }
  836. +       return false;
  837. +   }*/
  838. +  
  839. +   public static int indexOf(Object[] array, Object object) {
  840. +       for ( int i=0; i<array.length; i++ ) {
  841. +           if ( array[i].equals(object) ) return i;
  842. +       }
  843. +       return -1;
  844. +   }
  845. +  
  846. +   /*public static Object[] clone(Class elementClass, Object[] array) {
  847. +       Object[] result = (Object[]) Array.newInstance( elementClass, array.length );
  848. +       System.arraycopy(array, 0, result, 0, array.length);
  849. +       return result;
  850. +   }*/
  851. +
  852. +   public static String[] toStringArray(Object[] objects) {
  853. +       int length=objects.length;
  854. +       String[] result = new String[length];
  855. +       for (int i=0; i<length; i++) {
  856. +           result[i] = objects[i].toString();
  857. +       }
  858. +       return result;
  859. +   }
  860. +
  861. +   public static String[] fillArray(String value, int length) {
  862. +       String[] result = new String[length];
  863. +       Arrays.fill(result, value);
  864. +       return result;
  865. +   }
  866. +
  867. +   public static int[] fillArray(int value, int length) {
  868. +       int[] result = new int[length];
  869. +       Arrays.fill(result, value);
  870. +       return result;
  871. +   }
  872. +
  873. +   public static LockMode[] fillArray(LockMode lockMode, int length) {
  874. +       LockMode[] array = new LockMode[length];
  875. +       Arrays.fill(array, lockMode);
  876. +       return array;
  877. +   }
  878. +
  879. +   public static LockOptions[] fillArray(LockOptions lockOptions, int length) {
  880. +       LockOptions[] array = new LockOptions[length];
  881. +       Arrays.fill(array, lockOptions);
  882. +       return array;
  883. +   }
  884. +
  885. +   public static String[] toStringArray(Collection coll) {
  886. +       return (String[]) coll.toArray( new String[coll.size()] );
  887. +   }
  888. +  
  889. +   public static String[][] to2DStringArray(Collection coll) {
  890. +       return (String[][]) coll.toArray( new String[ coll.size() ][] );
  891. +   }
  892. +  
  893. +   public static int[][] to2DIntArray(Collection coll) {
  894. +       return (int[][]) coll.toArray( new int[ coll.size() ][] );
  895. +   }
  896. +  
  897. +   public static Type[] toTypeArray(Collection coll) {
  898. +       return (Type[]) coll.toArray( new Type[coll.size()] );
  899. +   }
  900. +
  901. +   public static int[] toIntArray(Collection coll) {
  902. +       Iterator iter = coll.iterator();
  903. +       int[] arr = new int[ coll.size() ];
  904. +       int i=0;
  905. +       while( iter.hasNext() ) {
  906. +           arr[i++] = ( (Integer) iter.next() ).intValue();
  907. +       }
  908. +       return arr;
  909. +   }
  910. +
  911. +   public static boolean[] toBooleanArray(Collection coll) {
  912. +       Iterator iter = coll.iterator();
  913. +       boolean[] arr = new boolean[ coll.size() ];
  914. +       int i=0;
  915. +       while( iter.hasNext() ) {
  916. +           arr[i++] = ( (Boolean) iter.next() ).booleanValue();
  917. +       }
  918. +       return arr;
  919. +   }
  920. +
  921. +   public static Object[] typecast(Object[] array, Object[] to) {
  922. +       return java.util.Arrays.asList(array).toArray(to);
  923. +   }
  924. +
  925. +   //Arrays.asList doesn't do primitive arrays
  926. +   public static List toList(Object array) {
  927. +       if ( array instanceof Object[] ) return Arrays.asList( (Object[]) array ); //faster?
  928. +       int size = Array.getLength(array);
  929. +       ArrayList list = new ArrayList(size);
  930. +       for (int i=0; i<size; i++) {
  931. +           list.add( Array.get(array, i) );
  932. +       }
  933. +       return list;
  934. +   }
  935. +
  936. +   public static String[] slice(String[] strings, int begin, int length) {
  937. +       String[] result = new String[length];
  938. +       System.arraycopy( strings, begin, result, 0, length );
  939. +       return result;
  940. +   }
  941. +
  942. +   public static Object[] slice(Object[] objects, int begin, int length) {
  943. +       Object[] result = new Object[length];
  944. +       System.arraycopy( objects, begin, result, 0, length );
  945. +       return result;
  946. +   }
  947. +
  948. +   public static List toList(Iterator iter) {
  949. +       List list = new ArrayList();
  950. +       while ( iter.hasNext() ) {
  951. +           list.add( iter.next() );
  952. +       }
  953. +       return list;
  954. +   }
  955. +
  956. +   public static String[] join(String[] x, String[] y) {
  957. +       String[] result = new String[ x.length + y.length ];
  958. +       System.arraycopy( x, 0, result, 0, x.length );
  959. +       System.arraycopy( y, 0, result, x.length, y.length );
  960. +       return result;
  961. +   }
  962. +
  963. +   public static String[] join(String[] x, String[] y, boolean[] use) {
  964. +       String[] result = new String[ x.length + countTrue(use) ];
  965. +       System.arraycopy( x, 0, result, 0, x.length );
  966. +       int k = x.length;
  967. +       for ( int i=0; i<y.length; i++ ) {
  968. +           if ( use[i] ) {
  969. +               result[k++] = y[i];
  970. +           }
  971. +       }
  972. +       return result;
  973. +   }
  974. +
  975. +   public static int[] join(int[] x, int[] y) {
  976. +       int[] result = new int[ x.length + y.length ];
  977. +       System.arraycopy( x, 0, result, 0, x.length );
  978. +       System.arraycopy( y, 0, result, x.length, y.length );
  979. +       return result;
  980. +   }
  981. +
  982. +   public static final boolean[] TRUE = { true };
  983. +   public static final boolean[] FALSE = { false };
  984. +
  985. +   private ArrayHelper() {}
  986. +
  987. +   public static String toString( Object[] array ) {
  988. +       StringBuffer sb = new StringBuffer();
  989. +       sb.append("[");
  990. +       for (int i = 0; i < array.length; i++) {
  991. +           sb.append( array[i] );
  992. +           if( i<array.length-1 ) sb.append(",");
  993. +       }
  994. +       sb.append("]");
  995. +       return sb.toString();
  996. +   }
  997. +
  998. +   public static boolean isAllNegative(int[] array) {
  999. +       for ( int i=0; i<array.length; i++ ) {
  1000. +           if ( array[i] >=0 ) return false;
  1001. +       }
  1002. +       return true;
  1003. +   }
  1004. +
  1005. +   public static boolean isAllTrue(boolean[] array) {
  1006. +       for ( int i=0; i<array.length; i++ ) {
  1007. +           if ( !array[i] ) return false;
  1008. +       }
  1009. +       return true;
  1010. +   }
  1011. +
  1012. +   public static int countTrue(boolean[] array) {
  1013. +       int result=0;
  1014. +       for ( int i=0; i<array.length; i++ ) {
  1015. +           if ( array[i] ) result++;
  1016. +       }
  1017. +       return result;
  1018. +   }
  1019. +
  1020. +   /*public static int countFalse(boolean[] array) {
  1021. +       int result=0;
  1022. +       for ( int i=0; i<array.length; i++ ) {
  1023. +           if ( !array[i] ) result++;
  1024. +       }
  1025. +       return result;
  1026. +   }*/
  1027. +
  1028. +   public static boolean isAllFalse(boolean[] array) {
  1029. +       for ( int i=0; i<array.length; i++ ) {
  1030. +           if ( array[i] ) return false;
  1031. +       }
  1032. +       return true;
  1033. +   }
  1034. +
  1035. +   public static void addAll(Collection collection, Object[] array) {
  1036. +       collection.addAll( Arrays.asList( array ) );
  1037. +   }
  1038. +
  1039. +   public static final String[] EMPTY_STRING_ARRAY = {};
  1040. +   public static final int[] EMPTY_INT_ARRAY = {};
  1041. +   public static final boolean[] EMPTY_BOOLEAN_ARRAY = {};
  1042. +   public static final Class[] EMPTY_CLASS_ARRAY = {};
  1043. +   public static final Object[] EMPTY_OBJECT_ARRAY = {};
  1044. +   public static final Type[] EMPTY_TYPE_ARRAY = {};
  1045. +  
  1046. +   public static int[] getBatchSizes(int maxBatchSize) {
  1047. +       int batchSize = maxBatchSize;
  1048. +       int n=1;
  1049. +       while ( batchSize>1 ) {
  1050. +           batchSize = getNextBatchSize(batchSize);
  1051. +           n++;
  1052. +       }
  1053. +       int[] result = new int[n];
  1054. +       batchSize = maxBatchSize;
  1055. +       for ( int i=0; i<n; i++ ) {
  1056. +           result[i] = batchSize;
  1057. +           batchSize = getNextBatchSize(batchSize);
  1058. +       }
  1059. +       return result;
  1060. +   }
  1061. +  
  1062. +   private static int getNextBatchSize(int batchSize) {
  1063. +       if (batchSize<=10) {
  1064. +           return batchSize-1; //allow 9,8,7,6,5,4,3,2,1
  1065. +       }
  1066. +       else if (batchSize/2 < 10) {
  1067. +           return 10;
  1068. +       }
  1069. +       else {
  1070. +           return batchSize / 2;
  1071. +       }
  1072. +   }
  1073. +
  1074. +   private static int SEED = 23;
  1075. +   private static int PRIME_NUMER = 37;
  1076. +
  1077. +   /**
  1078. +    * calculate the array hash (only the first level)
  1079. +    */
  1080. +   public static int hash(Object[] array) {
  1081. +       int length = array.length;
  1082. +       int seed = SEED;
  1083. +       for (int index = 0 ; index < length ; index++) {
  1084. +           seed = hash( seed, array[index] == null ? 0 : array[index].hashCode() );
  1085. +       }
  1086. +       return seed;
  1087. +   }
  1088. +
  1089. +   /**
  1090. +    * calculate the array hash (only the first level)
  1091. +    */
  1092. +   public static int hash(char[] array) {
  1093. +       int length = array.length;
  1094. +       int seed = SEED;
  1095. +       for (int index = 0 ; index < length ; index++) {
  1096. +           seed = hash( seed, (int) array[index] ) ;
  1097. +       }
  1098. +       return seed;
  1099. +   }
  1100. +
  1101. +   /**
  1102. +    * calculate the array hash (only the first level)
  1103. +    */
  1104. +   public static int hash(byte[] bytes) {
  1105. +       int length = bytes.length;
  1106. +       int seed = SEED;
  1107. +       for (int index = 0 ; index < length ; index++) {
  1108. +           seed = hash( seed, (int) bytes[index] ) ;
  1109. +       }
  1110. +       return seed;
  1111. +   }
  1112. +
  1113. +   private static int hash(int seed, int i) {
  1114. +       return PRIME_NUMER * seed + i;
  1115. +   }
  1116. +
  1117. +   /**
  1118. +    * Compare 2 arrays only at the first level
  1119. +    */
  1120. +   public static boolean isEquals(Object[] o1, Object[] o2) {
  1121. +       if (o1 == o2) return true;
  1122. +       if (o1 == null || o2 == null) return false;
  1123. +       int length = o1.length;
  1124. +       if (length != o2.length) return false;
  1125. +       for (int index = 0 ; index < length ; index++) {
  1126. +           if ( ! o1[index].equals( o2[index] ) ) return false;
  1127. +       }
  1128. +        return true;
  1129. +   }
  1130. +
  1131. +   /**
  1132. +    * Compare 2 arrays only at the first level
  1133. +    */
  1134. +   public static boolean isEquals(char[] o1, char[] o2) {
  1135. +       if (o1 == o2) return true;
  1136. +       if (o1 == null || o2 == null) return false;
  1137. +       int length = o1.length;
  1138. +       if (length != o2.length) return false;
  1139. +       for (int index = 0 ; index < length ; index++) {
  1140. +           if ( ! ( o1[index] == o2[index] ) ) return false;
  1141. +       }
  1142. +        return true;
  1143. +   }
  1144. +
  1145. +   /**
  1146. +    * Compare 2 arrays only at the first level
  1147. +    */
  1148. +   public static boolean isEquals(byte[] b1, byte[] b2) {
  1149. +       if (b1 == b2) return true;
  1150. +       if (b1 == null || b2 == null) return false;
  1151. +       int length = b1.length;
  1152. +       if (length != b2.length) return false;
  1153. +       for (int index = 0 ; index < length ; index++) {
  1154. +           if ( ! ( b1[index] == b2[index] ) ) return false;
  1155. +       }
  1156. +        return true;
  1157. +   }
  1158. +}
  1159. +
  1160. +
  1161. +
  1162. +
  1163. +
  1164. +
  1165.  
  1166. Property changes on: src\main\java\org\hibernate\util\ArrayHelper.java
  1167. ___________________________________________________________________
  1168. Added: svn:mime-type
  1169.    + text/plain
  1170.  
  1171. Index: src/main/java/org/jbpm/ant/ShutDownHsqldb.java
  1172. ===================================================================
  1173. --- src/main/java/org/jbpm/ant/ShutDownHsqldb.java  (revision 65983)
  1174. +++ src/main/java/org/jbpm/ant/ShutDownHsqldb.java  (revision 75353)
  1175. @@ -6,8 +6,8 @@
  1176.  
  1177.  import org.apache.tools.ant.BuildException;
  1178.  import org.apache.tools.ant.Task;
  1179. -import org.hibernate.connection.ConnectionProvider;
  1180. -import org.hibernate.impl.SessionFactoryImpl;
  1181. +//import org.hibernate.connection.ConnectionProvider;
  1182. +//import org.hibernate.impl.SessionFactoryImpl;
  1183.  import org.jbpm.JbpmConfiguration;
  1184.  import org.jbpm.JbpmContext;
  1185.  import org.jbpm.persistence.db.DbPersistenceServiceFactory;
  1186. @@ -19,21 +19,21 @@
  1187.      Connection connection = null;
  1188.      JbpmConfiguration jbpmConfiguration = AntHelper.getJbpmConfiguration(null);
  1189.      JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  1190. -    try {
  1191. -      DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
  1192. -      SessionFactoryImpl sessionFactory = (SessionFactoryImpl) dbPersistenceServiceFactory.getSessionFactory();
  1193. -      ConnectionProvider connectionProvider = sessionFactory.getConnectionProvider();
  1194. -      connection = connectionProvider.getConnection();
  1195. -      Statement statement = connection.createStatement();
  1196. -      log("shutting down database");
  1197. -      statement.executeUpdate("SHUTDOWN");
  1198. -      connection.close();
  1199. -      
  1200. -    } catch (SQLException e) {
  1201. -      e.printStackTrace();
  1202. -    } finally {
  1203. -      jbpmContext.close();
  1204. -    }
  1205. +//    try {
  1206. +//      DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmContext.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
  1207. +//      SessionFactoryImpl sessionFactory = (SessionFactoryImpl) dbPersistenceServiceFactory.getSessionFactory();
  1208. +//      ConnectionProvider connectionProvider = sessionFactory.getConnectionProvider();
  1209. +//      connection = connectionProvider.getConnection();
  1210. +//      Statement statement = connection.createStatement();
  1211. +//      log("shutting down database");
  1212. +//      statement.executeUpdate("SHUTDOWN");
  1213. +//      connection.close();
  1214. +//      
  1215. +//    } catch (SQLException e) {
  1216. +//      e.printStackTrace();
  1217. +//    } finally {
  1218. +//      jbpmContext.close();
  1219. +//    }
  1220.    }
  1221.  
  1222.  }
  1223. Index: src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
  1224. ===================================================================
  1225. --- src/main/java/org/jbpm/persistence/db/DbPersistenceService.java (revision 65983)
  1226. +++ src/main/java/org/jbpm/persistence/db/DbPersistenceService.java (revision 75353)
  1227. @@ -22,6 +22,7 @@
  1228.  package org.jbpm.persistence.db;
  1229.  
  1230.  import java.sql.Connection;
  1231. +import java.sql.SQLException;
  1232.  
  1233.  import javax.sql.DataSource;
  1234.  
  1235. @@ -43,421 +44,463 @@
  1236.  import org.jbpm.svc.Service;
  1237.  import org.jbpm.svc.Services;
  1238.  import org.jbpm.tx.TxService;
  1239. +import org.hibernate.jdbc.Work;
  1240.  
  1241.  public class DbPersistenceService implements Service, PersistenceService {
  1242. -  
  1243. -  private static final long serialVersionUID = 1L;
  1244. +
  1245. +   private static final long serialVersionUID = 1L;
  1246. +
  1247. +   protected DbPersistenceServiceFactory persistenceServiceFactory = null;
  1248. +
  1249. +   protected Connection connection = null;
  1250. +   protected boolean mustConnectionBeClosed = false;
  1251. +
  1252. +   protected Transaction transaction = null;
  1253. +   protected boolean isTransactionEnabled = true;
  1254. +   protected boolean isCurrentSessionEnabled = false;
  1255. +
  1256. +   // boolean isRollbackOnly = false;
  1257. +
  1258. +   protected Session session;
  1259. +   protected boolean mustSessionBeFlushed = false;
  1260. +   protected boolean mustSessionBeClosed = false;
  1261. +
  1262. +   protected Services services = null;
  1263. +
  1264. +   protected GraphSession graphSession = null;
  1265. +   protected TaskMgmtSession taskMgmtSession = null;
  1266. +   protected JobSession jobSession = null;
  1267. +   protected ContextSession contextSession = null;
  1268. +   protected LoggingSession loggingSession = null;
  1269. +
  1270. +   public DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
  1271. +       this(persistenceServiceFactory, getCurrentServices());
  1272. +   }
  1273. +
  1274. +   static Services getCurrentServices() {
  1275. +       Services services = null;
  1276. +       JbpmContext currentJbpmContext = JbpmContext.getCurrentJbpmContext();
  1277. +       if (currentJbpmContext != null) {
  1278. +           services = currentJbpmContext.getServices();
  1279. +       }
  1280. +       return services;
  1281. +   }
  1282.  
  1283. -  protected DbPersistenceServiceFactory persistenceServiceFactory = null;
  1284. +   DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory, Services services) {
  1285. +       this.persistenceServiceFactory = persistenceServiceFactory;
  1286. +       this.isTransactionEnabled = persistenceServiceFactory.isTransactionEnabled();
  1287. +       this.isCurrentSessionEnabled = persistenceServiceFactory.isCurrentSessionEnabled();
  1288. +       this.services = services;
  1289. +   }
  1290.  
  1291. -  protected Connection connection = null;
  1292. -  protected boolean mustConnectionBeClosed = false;
  1293. +   public SessionFactory getSessionFactory() {
  1294. +       return persistenceServiceFactory.getSessionFactory();
  1295. +   }
  1296.  
  1297. -  protected Transaction transaction = null;
  1298. -  protected boolean isTransactionEnabled = true;
  1299. -  protected boolean isCurrentSessionEnabled = false;
  1300. +   public Session getSession() {
  1301. +       if ((session == null) && (getSessionFactory() != null)) {
  1302. +           Connection connection = getConnection(false);
  1303. +           if (isCurrentSessionEnabled) {
  1304. +               session = getSessionFactory().getCurrentSession();
  1305. +               log.debug("using current hibernate session " + session);
  1306. +               mustSessionBeClosed = false;
  1307. +               mustSessionBeFlushed = false;
  1308. +               mustConnectionBeClosed = false;
  1309. +           } else if (connection != null) {
  1310. +               log.debug("creating hibernate session with connection " + connection);
  1311. +               session = getSessionFactory().openSession();
  1312. +               session.reconnect(connection);
  1313. +               mustSessionBeClosed = true;
  1314. +               mustSessionBeFlushed = true;
  1315. +               mustConnectionBeClosed = false;
  1316. +           } else {
  1317. +               log.debug("creating hibernate session");
  1318. +               session = getSessionFactory().openSession();
  1319. +               mustSessionBeClosed = true;
  1320. +               mustSessionBeFlushed = true;
  1321. +               mustConnectionBeClosed = false;
  1322. +           }
  1323.  
  1324. -  // boolean isRollbackOnly = false;
  1325. +           if (isTransactionEnabled) {
  1326. +               beginTransaction();
  1327. +           }
  1328. +       }
  1329. +       return session;
  1330. +   }
  1331.  
  1332. -  protected Session session;
  1333. -  protected boolean mustSessionBeFlushed = false;
  1334. -  protected boolean mustSessionBeClosed = false;
  1335. +   public void beginTransaction() {
  1336. +       log.debug("beginning hibernate transaction");
  1337. +       transaction = session.beginTransaction();
  1338. +       log.debug("begun hibernate transaction " + transaction.toString());
  1339. +   }
  1340.  
  1341. -  protected Services services = null;
  1342. +   public void endTransaction() {
  1343. +       if ((isTransactionEnabled) && (transaction != null)) {
  1344. +           if (isRollbackOnly()) {
  1345. +               try {
  1346. +                   log.debug("rolling back hibernate transaction " + transaction.toString());
  1347. +                   mustSessionBeFlushed = false; // flushing updates that will
  1348. +                                                   // be rolled back is not
  1349. +                                                   // very clever :-)
  1350. +                   transaction.rollback();
  1351. +               } catch (Exception e) {
  1352. +                   // NOTE that Error's are not caught because that might halt
  1353. +                   // the JVM and mask the original Error.
  1354. +                   throw new JbpmPersistenceException("couldn't rollback hibernate session", e);
  1355. +               }
  1356. +           } else {
  1357. +               try {
  1358. +                   log.debug("committing hibernate transaction " + transaction.toString());
  1359. +                   mustSessionBeFlushed = false; // commit does a flush anyway
  1360. +                   transaction.commit();
  1361. +               } catch (Exception e) {
  1362. +                   // NOTE that Error's are not caught because that might halt
  1363. +                   // the JVM and mask the original Error.
  1364. +                   try {
  1365. +                       // if the commit fails, we must do a rollback
  1366. +                       transaction.rollback();
  1367. +                   } catch (Exception e2) {
  1368. +                       // if the rollback fails, we did what we could and
  1369. +                       // you're in
  1370. +                       // deep shit :-(
  1371. +                       log.error("problem rolling back after failed commit", e2);
  1372. +                   }
  1373. +                   throw new JbpmPersistenceException("couldn't commit hibernate session", e);
  1374. +               }
  1375. +           }
  1376. +       }
  1377. +   }
  1378.  
  1379. -  protected GraphSession graphSession = null;
  1380. -  protected TaskMgmtSession taskMgmtSession = null;
  1381. -  protected JobSession jobSession = null;
  1382. -  protected ContextSession contextSession = null;
  1383. -  protected LoggingSession loggingSession = null;
  1384. +   public Connection getConnection() {
  1385. +       return getConnection(true);
  1386. +   }
  1387.  
  1388. -  public DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
  1389. -    this(persistenceServiceFactory, getCurrentServices());
  1390. -  }
  1391. +   public Connection getConnection(boolean resolveSession) {
  1392. +       if (connection == null) {
  1393. +           if (persistenceServiceFactory.getDataSource() != null) {
  1394. +               try {
  1395. +                   log.debug("fetching jdbc connection from datasource");
  1396. +                   connection = persistenceServiceFactory.getDataSource().getConnection();
  1397. +                   mustConnectionBeClosed = true;
  1398. +               } catch (Exception e) {
  1399. +                   // NOTE that Error's are not caught because that might halt
  1400. +                   // the JVM and mask the original Error.
  1401. +                   throw new JbpmException("couldn't obtain connection from datasource", e);
  1402. +               }
  1403. +           } else {
  1404. +               if (resolveSession) {
  1405. +                   // initializes the session member
  1406. +                   getSession();
  1407. +               }
  1408. +               if (session != null) {
  1409. +                   GetConnectionWork work = new GetConnectionWork();
  1410. +                   session.doWork(work);
  1411. +                   connection = work.getConnection();
  1412. +                   log.debug("fetching connection from hibernate session. this transfers responsibility for closing the jdbc connection to the user! "
  1413. +                           + connection);
  1414. +                   mustConnectionBeClosed = false;
  1415. +               }
  1416. +           }
  1417. +       }
  1418. +       return connection;
  1419. +   }
  1420.  
  1421. -  static Services getCurrentServices() {
  1422. -    Services services = null;
  1423. -    JbpmContext currentJbpmContext = JbpmContext.getCurrentJbpmContext();
  1424. -    if (currentJbpmContext!=null) {
  1425. -      services = currentJbpmContext.getServices();
  1426. -    }
  1427. -    return services;
  1428. -  }
  1429. +   public void close() {
  1430.  
  1431. -  DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory, Services services) {
  1432. -    this.persistenceServiceFactory = persistenceServiceFactory;
  1433. -    this.isTransactionEnabled = persistenceServiceFactory.isTransactionEnabled();
  1434. -    this.isCurrentSessionEnabled = persistenceServiceFactory.isCurrentSessionEnabled();
  1435. -    this.services = services;
  1436. -  }
  1437. +       if ((session != null) && (transaction == null) && (isRollbackOnly())) {
  1438. +           throw new JbpmException(
  1439. +                   "setRollbackOnly was invoked while configuration specifies user managed transactions");
  1440. +       }
  1441.  
  1442. -  public SessionFactory getSessionFactory() {
  1443. -    return persistenceServiceFactory.getSessionFactory();
  1444. -  }
  1445. +       if ((isTransactionEnabled) && (transaction != null)) {
  1446.  
  1447. -  public Session getSession() {
  1448. -    if ( (session==null)
  1449. -         && (getSessionFactory()!=null)
  1450. -       ) {
  1451. -      Connection connection = getConnection(false);
  1452. -      if (isCurrentSessionEnabled) {
  1453. -        session = getSessionFactory().getCurrentSession();
  1454. -        log.debug("using current hibernate session " + session);
  1455. -        mustSessionBeClosed = false;
  1456. -        mustSessionBeFlushed = false;
  1457. -        mustConnectionBeClosed = false;
  1458. -      } else if (connection!=null) {
  1459. -        log.debug("creating hibernate session with connection "+connection);
  1460. -        session = getSessionFactory().openSession(connection);
  1461. -        mustSessionBeClosed = true;
  1462. -        mustSessionBeFlushed = true;
  1463. -        mustConnectionBeClosed = false;
  1464. -      } else {
  1465. -        log.debug("creating hibernate session");
  1466. -        session = getSessionFactory().openSession();
  1467. -        mustSessionBeClosed = true;
  1468. -        mustSessionBeFlushed = true;
  1469. -        mustConnectionBeClosed = false;
  1470. -      }
  1471. -      
  1472. -      if (isTransactionEnabled) {
  1473. -        beginTransaction();
  1474. -      }
  1475. -    }
  1476. -    return session;
  1477. -  }
  1478. +           if (!isRollbackOnly()) {
  1479. +               Exception commitException = commit();
  1480. +               if (commitException != null) {
  1481. +                   rollback();
  1482. +                   closeSession();
  1483. +                   closeConnection();
  1484. +                   throw new JbpmPersistenceException("hibernate commit failed", commitException);
  1485. +               }
  1486.  
  1487. -  public void beginTransaction() {
  1488. -    log.debug("beginning hibernate transaction");
  1489. -    transaction = session.beginTransaction();
  1490. -    log.debug("begun hibernate transaction " + transaction.toString());
  1491. -  }
  1492. +           } else { // isRollbackOnly==true
  1493. +               Exception rollbackException = rollback();
  1494. +               if (rollbackException != null) {
  1495. +                   closeSession();
  1496. +                   closeConnection();
  1497. +                   throw new JbpmPersistenceException("hibernate rollback failed", rollbackException);
  1498. +               }
  1499. +           }
  1500. +       }
  1501.  
  1502. -  public void endTransaction() {
  1503. -    if ( (isTransactionEnabled)
  1504. -         && (transaction!=null)
  1505. -       ) {
  1506. -      if (isRollbackOnly()) {
  1507. -        try {
  1508. -          log.debug("rolling back hibernate transaction " + transaction.toString());
  1509. -          mustSessionBeFlushed = false; // flushing updates that will be rolled back is not very clever :-)
  1510. -          transaction.rollback();
  1511. -        } catch (Exception e) {
  1512. -          // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
  1513. -          throw new JbpmPersistenceException("couldn't rollback hibernate session", e);
  1514. -        }
  1515. -      } else {
  1516. -        try {
  1517. -          log.debug("committing hibernate transaction " + transaction.toString());
  1518. -          mustSessionBeFlushed = false; // commit does a flush anyway
  1519. -          transaction.commit();
  1520. -        } catch (Exception e) {
  1521. -          // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
  1522. -          try {
  1523. -            // if the commit fails, we must do a rollback
  1524. -            transaction.rollback();
  1525. -          } catch (Exception e2) {
  1526. -            // if the rollback fails, we did what we could and you're in
  1527. -            // deep shit :-(
  1528. -            log.error("problem rolling back after failed commit", e2);
  1529. -          }
  1530. -          throw new JbpmPersistenceException("couldn't commit hibernate session", e);
  1531. -        }
  1532. -      }
  1533. -    }
  1534. -  }
  1535. +       Exception flushException = flushSession();
  1536. +       if (flushException != null) {
  1537. +           rollback();
  1538. +           closeSession();
  1539. +           closeConnection();
  1540. +           throw new JbpmPersistenceException("hibernate flush failed", flushException);
  1541. +       }
  1542.  
  1543. -  public Connection getConnection() {
  1544. -    return getConnection(true);
  1545. -  }
  1546. +       Exception closeSessionException = closeSession();
  1547. +       if (closeSessionException != null) {
  1548. +           closeConnection();
  1549. +           throw new JbpmPersistenceException("hibernate close session failed", closeSessionException);
  1550. +       }
  1551.  
  1552. -  public Connection getConnection(boolean resolveSession) {
  1553. -    if (connection==null) {
  1554. -      if (persistenceServiceFactory.getDataSource()!=null) {
  1555. -        try {
  1556. -          log.debug("fetching jdbc connection from datasource");
  1557. -          connection = persistenceServiceFactory.getDataSource().getConnection();
  1558. -          mustConnectionBeClosed = true;
  1559. -        } catch (Exception e) {
  1560. -          // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
  1561. -          throw new JbpmException("couldn't obtain connection from datasource", e);
  1562. -        }
  1563. -      } else {
  1564. -        if (resolveSession) {
  1565. -          // initializes the session member
  1566. -          getSession();
  1567. -        }
  1568. -        if (session!=null) {
  1569. -          connection = session.connection();
  1570. -          log.debug("fetching connection from hibernate session. this transfers responsibility for closing the jdbc connection to the user! "+connection);
  1571. -          mustConnectionBeClosed = false;
  1572. -        }
  1573. -      }
  1574. -    }
  1575. -    return connection;
  1576. -  }
  1577. -  
  1578. -  public void close() {
  1579. +       Exception closeConnectionException = closeConnection();
  1580. +       if (closeConnectionException != null) {
  1581. +           throw new JbpmPersistenceException("hibernate close connection failed", closeConnectionException);
  1582. +       }
  1583. +   }
  1584.  
  1585. -    if ( (session!=null)
  1586. -         && (transaction==null)
  1587. -         && (isRollbackOnly())
  1588. -       ) {
  1589. -      throw new JbpmException("setRollbackOnly was invoked while configuration specifies user managed transactions");
  1590. -    }
  1591. -    
  1592. -    if ( (isTransactionEnabled)
  1593. -         && (transaction!=null)
  1594. -       ) {
  1595. +   Exception commit() {
  1596. +       try {
  1597. +           log.debug("committing hibernate transaction " + transaction.toString());
  1598. +           mustSessionBeFlushed = false; // commit does a flush anyway
  1599. +           transaction.commit();
  1600. +       } catch (StaleObjectStateException e) {
  1601. +           log.info("optimistic locking failed");
  1602. +           StaleObjectLogConfigurer.staleObjectExceptionsLog.error("optimistic locking failed", e);
  1603. +           return e;
  1604. +       } catch (Exception e) {
  1605. +           log.error("hibernate commit failed", e);
  1606. +           return e;
  1607. +       }
  1608. +       return null;
  1609. +   }
  1610.  
  1611. -      if (! isRollbackOnly()) {
  1612. -        Exception commitException = commit();
  1613. -        if (commitException!=null) {
  1614. -          rollback();
  1615. -          closeSession();
  1616. -          closeConnection();
  1617. -          throw new JbpmPersistenceException("hibernate commit failed", commitException);
  1618. -        }
  1619. +   Exception flushSession() {
  1620. +       if (mustSessionBeFlushed) {
  1621. +           try {
  1622. +               log.debug("flushing hibernate session " + session.toString());
  1623. +               session.flush();
  1624. +           } catch (Exception e) {
  1625. +               log.error("hibernate flush failed", e);
  1626. +               return e;
  1627. +           }
  1628. +       }
  1629. +       return null;
  1630. +   }
  1631.  
  1632. -      } else { // isRollbackOnly==true
  1633. -        Exception rollbackException = rollback();
  1634. -        if (rollbackException!=null) {
  1635. -          closeSession();
  1636. -          closeConnection();
  1637. -          throw new JbpmPersistenceException("hibernate rollback failed", rollbackException);
  1638. -        }
  1639. -      }
  1640. -    }
  1641. -    
  1642. -    Exception flushException = flushSession();
  1643. -    if (flushException!=null) {
  1644. -      rollback();
  1645. -      closeSession();
  1646. -      closeConnection();
  1647. -      throw new JbpmPersistenceException("hibernate flush failed", flushException);
  1648. -    }
  1649. +   Exception closeConnection() {
  1650. +       if (mustConnectionBeClosed) {
  1651. +           try {
  1652. +               if ((connection != null) && (!connection.isClosed())) {
  1653. +                   log.debug("closing jdbc connection");
  1654. +                   connection.close();
  1655. +               } else {
  1656. +                   log.warn("jdbc connection was already closed");
  1657. +               }
  1658. +           } catch (Exception e) {
  1659. +               log.error("hibernate session close failed", e);
  1660. +               return e;
  1661. +           }
  1662. +       }
  1663. +       return null;
  1664. +   }
  1665.  
  1666. -    Exception closeSessionException = closeSession();
  1667. -    if (closeSessionException!=null) {
  1668. -      closeConnection();
  1669. -      throw new JbpmPersistenceException("hibernate close session failed", closeSessionException);
  1670. -    }
  1671. +   Exception rollback() {
  1672. +       try {
  1673. +           log.debug("rolling back hibernate transaction");
  1674. +           mustSessionBeFlushed = false; // flushing updates that will be
  1675. +                                           // rolled back is not very clever
  1676. +                                           // :-)
  1677. +           transaction.rollback();
  1678. +       } catch (Exception e) {
  1679. +           log.error("hibernate rollback failed", e);
  1680. +           return e;
  1681. +       }
  1682. +       return null;
  1683. +   }
  1684.  
  1685. -    Exception closeConnectionException = closeConnection();
  1686. -    if (closeConnectionException!=null) {
  1687. -      throw new JbpmPersistenceException("hibernate close connection failed", closeConnectionException);
  1688. -    }
  1689. -  }
  1690. +   Exception closeSession() {
  1691. +       if (mustSessionBeClosed) {
  1692. +           try {
  1693. +               if (session.isOpen()) {
  1694. +                   log.debug("closing hibernate session");
  1695. +                   session.close();
  1696. +               } else {
  1697. +                   log.warn("hibernate session was already closed");
  1698. +               }
  1699. +           } catch (Exception e) {
  1700. +               return e;
  1701. +           }
  1702. +       }
  1703. +       return null;
  1704. +   }
  1705.  
  1706. -  Exception commit() {
  1707. -    try {
  1708. -      log.debug("committing hibernate transaction " + transaction.toString());
  1709. -      mustSessionBeFlushed = false; // commit does a flush anyway
  1710. -      transaction.commit();
  1711. -    } catch (StaleObjectStateException e) {
  1712. -      log.info("optimistic locking failed");
  1713. -      StaleObjectLogConfigurer.staleObjectExceptionsLog.error("optimistic locking failed", e);
  1714. -      return e;
  1715. -    } catch (Exception e) {
  1716. -      log.error("hibernate commit failed", e);
  1717. -      return e;
  1718. -    }
  1719. -    return null;
  1720. -  }
  1721. +   public void assignId(Object object) {
  1722. +       try {
  1723. +           getSession().save(object);
  1724. +       } catch (Exception e) {
  1725. +           // NOTE that Error's are not caught because that might halt the JVM
  1726. +           // and mask the original Error.
  1727. +           throw new JbpmPersistenceException("couldn't assign id to " + object, e);
  1728. +       }
  1729. +   }
  1730.  
  1731. -  Exception flushSession() {
  1732. -    if (mustSessionBeFlushed) {
  1733. -      try {
  1734. -        log.debug("flushing hibernate session " + session.toString());
  1735. -        session.flush();
  1736. -      } catch (Exception e) {
  1737. -        log.error("hibernate flush failed", e);
  1738. -        return e;
  1739. -      }
  1740. -    }
  1741. -    return null;
  1742. -  }
  1743. +   // getters and setters
  1744. +   // //////////////////////////////////////////////////////
  1745.  
  1746. -  Exception closeConnection() {
  1747. -    if (mustConnectionBeClosed) {
  1748. -      try {
  1749. -        if ( (connection!=null)
  1750. -            && (! connection.isClosed())
  1751. -           ) {
  1752. -          log.debug("closing jdbc connection");
  1753. -          connection.close();
  1754. -        } else {
  1755. -          log.warn("jdbc connection was already closed");
  1756. -        }
  1757. -      } catch (Exception e) {
  1758. -        log.error("hibernate session close failed", e);
  1759. -        return e;
  1760. -      }
  1761. -    }
  1762. -    return null;
  1763. -  }
  1764. +   public GraphSession getGraphSession() {
  1765. +       if (graphSession == null) {
  1766. +           Session session = getSession();
  1767. +           if (session != null) {
  1768. +               graphSession = new GraphSession(session);
  1769. +           }
  1770. +       }
  1771. +       return graphSession;
  1772. +   }
  1773.  
  1774. -  Exception rollback() {
  1775. -    try {
  1776. -      log.debug("rolling back hibernate transaction");
  1777. -      mustSessionBeFlushed = false; // flushing updates that will be rolled back is not very clever :-)
  1778. -      transaction.rollback();
  1779. -    } catch (Exception e) {
  1780. -      log.error("hibernate rollback failed", e);
  1781. -      return e;
  1782. -    }
  1783. -    return null;
  1784. -  }
  1785. +   public LoggingSession getLoggingSession() {
  1786. +       if (loggingSession == null) {
  1787. +           Session session = getSession();
  1788. +           if (session != null) {
  1789. +               loggingSession = new LoggingSession(session);
  1790. +           }
  1791. +       }
  1792. +       return loggingSession;
  1793. +   }
  1794.  
  1795. -  Exception closeSession() {
  1796. -    if (mustSessionBeClosed) {
  1797. -      try {
  1798. -        if(session.isOpen()) {
  1799. -          log.debug("closing hibernate session");
  1800. -          session.close();
  1801. -        } else {
  1802. -          log.warn("hibernate session was already closed");
  1803. -        }
  1804. -      } catch (Exception e) {
  1805. -        return e;
  1806. -      }
  1807. -    }
  1808. -    return null;
  1809. -  }
  1810. +   public JobSession getJobSession() {
  1811. +       if (jobSession == null) {
  1812. +           Session session = getSession();
  1813. +           if (session != null) {
  1814. +               jobSession = new JobSession(session);
  1815. +           }
  1816. +       }
  1817. +       return jobSession;
  1818. +   }
  1819.  
  1820. -  public void assignId(Object object) {
  1821. -    try {
  1822. -      getSession().save(object);
  1823. -    } catch (Exception e) {
  1824. -      // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
  1825. -      throw new JbpmPersistenceException("couldn't assign id to "+object, e);
  1826. -    }
  1827. -  }
  1828. +   public ContextSession getContextSession() {
  1829. +       if (contextSession == null) {
  1830. +           Session session = getSession();
  1831. +           if (session != null) {
  1832. +               contextSession = new ContextSession(session);
  1833. +           }
  1834. +       }
  1835. +       return contextSession;
  1836. +   }
  1837.  
  1838. -  // getters and setters //////////////////////////////////////////////////////
  1839. +   public TaskMgmtSession getTaskMgmtSession() {
  1840. +       if (taskMgmtSession == null) {
  1841. +           Session session = getSession();
  1842. +           if (session != null) {
  1843. +               taskMgmtSession = new TaskMgmtSession(session);
  1844. +           }
  1845. +       }
  1846. +       return taskMgmtSession;
  1847. +   }
  1848.  
  1849. -  public GraphSession getGraphSession() {
  1850. -    if (graphSession==null) {
  1851. -      Session session = getSession();
  1852. -      if (session!=null) {
  1853. -        graphSession = new GraphSession(session);
  1854. -      }
  1855. -    }
  1856. -    return graphSession;
  1857. -  }
  1858. -  public LoggingSession getLoggingSession() {
  1859. -    if (loggingSession==null) {
  1860. -      Session session = getSession();
  1861. -      if (session!=null) {
  1862. -        loggingSession = new LoggingSession(session);
  1863. -      }
  1864. -    }
  1865. -    return loggingSession;
  1866. -  }
  1867. -  public JobSession getJobSession() {
  1868. -    if (jobSession==null) {
  1869. -      Session session = getSession();
  1870. -      if (session!=null) {
  1871. -        jobSession = new JobSession(session);
  1872. -      }
  1873. -    }
  1874. -    return jobSession;
  1875. -  }
  1876. -  public ContextSession getContextSession() {
  1877. -    if (contextSession==null) {
  1878. -      Session session = getSession();
  1879. -      if (session!=null) {
  1880. -        contextSession = new ContextSession(session);
  1881. -      }
  1882. -    }
  1883. -    return contextSession;
  1884. -  }
  1885. -  public TaskMgmtSession getTaskMgmtSession() {
  1886. -    if (taskMgmtSession==null) {
  1887. -      Session session = getSession();
  1888. -      if (session!=null) {
  1889. -        taskMgmtSession = new TaskMgmtSession(session);
  1890. -      }
  1891. -    }
  1892. -    return taskMgmtSession;
  1893. -  }
  1894. +   public DataSource getDataSource() {
  1895. +       return persistenceServiceFactory.dataSource;
  1896. +   }
  1897.  
  1898. -  public DataSource getDataSource() {
  1899. -    return persistenceServiceFactory.dataSource;
  1900. -  }
  1901. +   /**
  1902. +    * @deprecated use {@link org.jbpm.tx.TxService} instead.
  1903. +    */
  1904. +   public boolean isRollbackOnly() {
  1905. +       TxService txService = (services != null ? services.getTxService() : null);
  1906. +       if (txService == null) {
  1907. +           throw new JbpmException("no jbpm tx service configured");
  1908. +       }
  1909. +       return txService.isRollbackOnly();
  1910. +   }
  1911.  
  1912. -  /**
  1913. -   * @deprecated use {@link org.jbpm.tx.TxService} instead.
  1914. -   */
  1915. -  public boolean isRollbackOnly() {
  1916. -    TxService txService = (services!=null ? services.getTxService() : null);
  1917. -    if (txService==null) {
  1918. -      throw new JbpmException("no jbpm tx service configured");
  1919. -    }
  1920. -    return txService.isRollbackOnly();
  1921. -  }
  1922. -  /**
  1923. -   * @deprecated use {@link org.jbpm.tx.TxService} instead.
  1924. -   */
  1925. -  public void setRollbackOnly(boolean isRollbackOnly) {
  1926. -    throw new UnsupportedOperationException("method setRollbackOnly has been removed.  Use TxService instead.");
  1927. -  }
  1928. -  /**
  1929. -   * @deprecated use {@link org.jbpm.tx.TxService} instead.
  1930. -   */
  1931. -  public void setRollbackOnly() {
  1932. -    TxService txService = (services!=null ? services.getTxService() : null);
  1933. -    if (txService==null) {
  1934. -      throw new JbpmException("no jbpm tx service configured");
  1935. -    }
  1936. -    txService.setRollbackOnly();
  1937. -  }
  1938. +   /**
  1939. +    * @deprecated use {@link org.jbpm.tx.TxService} instead.
  1940. +    */
  1941. +   public void setRollbackOnly(boolean isRollbackOnly) {
  1942. +       throw new UnsupportedOperationException("method setRollbackOnly has been removed.  Use TxService instead.");
  1943. +   }
  1944.  
  1945. -  public void setSession(Session session) {
  1946. -    this.session = session;
  1947. -    log.debug("injecting a session disables transaction");
  1948. -    isTransactionEnabled = false;
  1949. -  }
  1950. +   /**
  1951. +    * @deprecated use {@link org.jbpm.tx.TxService} instead.
  1952. +    */
  1953. +   public void setRollbackOnly() {
  1954. +       TxService txService = (services != null ? services.getTxService() : null);
  1955. +       if (txService == null) {
  1956. +           throw new JbpmException("no jbpm tx service configured");
  1957. +       }
  1958. +       txService.setRollbackOnly();
  1959. +   }
  1960.  
  1961. -  public void setSessionWithoutDisablingTx(Session session) {
  1962. -    this.session = session;
  1963. -  }
  1964. +   public void setSession(Session session) {
  1965. +       this.session = session;
  1966. +       log.debug("injecting a session disables transaction");
  1967. +       isTransactionEnabled = false;
  1968. +   }
  1969.  
  1970. -  public void setConnection(Connection connection) {
  1971. -    this.connection = connection;
  1972. -  }
  1973. -  public void setContextSession(ContextSession contextSession) {
  1974. -    this.contextSession = contextSession;
  1975. -  }
  1976. -  public void setDataSource(DataSource dataSource) {
  1977. -    this.persistenceServiceFactory.dataSource = dataSource;
  1978. -  }
  1979. -  public void setGraphSession(GraphSession graphSession) {
  1980. -    this.graphSession = graphSession;
  1981. -  }
  1982. -  public void setLoggingSession(LoggingSession loggingSession) {
  1983. -    this.loggingSession = loggingSession;
  1984. -  }
  1985. -  public void setJobSession(JobSession jobSession) {
  1986. -    this.jobSession = jobSession;
  1987. -  }
  1988. -  public void setTaskMgmtSession(TaskMgmtSession taskMgmtSession) {
  1989. -    this.taskMgmtSession = taskMgmtSession;
  1990. -  }
  1991. -  public void setSessionFactory(SessionFactory sessionFactory) {
  1992. -    this.persistenceServiceFactory.sessionFactory = sessionFactory;
  1993. -  }
  1994. -  public Transaction getTransaction() {
  1995. -    return transaction;
  1996. -  }
  1997. -  public void setTransaction(Transaction transaction) {
  1998. -    this.transaction = transaction;
  1999. -  }
  2000. -  public boolean isTransactionEnabled() {
  2001. -    return isTransactionEnabled;
  2002. -  }
  2003. -  public void setTransactionEnabled(boolean isTransactionEnabled) {
  2004. -    this.isTransactionEnabled = isTransactionEnabled;
  2005. -  }
  2006. -  private static Log log = LogFactory.getLog(DbPersistenceService.class);
  2007. +   public void setSessionWithoutDisablingTx(Session session) {
  2008. +       this.session = session;
  2009. +   }
  2010. +
  2011. +   public void setConnection(Connection connection) {
  2012. +       this.connection = connection;
  2013. +   }
  2014. +
  2015. +   public void setContextSession(ContextSession contextSession) {
  2016. +       this.contextSession = contextSession;
  2017. +   }
  2018. +
  2019. +   public void setDataSource(DataSource dataSource) {
  2020. +       this.persistenceServiceFactory.dataSource = dataSource;
  2021. +   }
  2022. +
  2023. +   public void setGraphSession(GraphSession graphSession) {
  2024. +       this.graphSession = graphSession;
  2025. +   }
  2026. +
  2027. +   public void setLoggingSession(LoggingSession loggingSession) {
  2028. +       this.loggingSession = loggingSession;
  2029. +   }
  2030. +
  2031. +   public void setJobSession(JobSession jobSession) {
  2032. +       this.jobSession = jobSession;
  2033. +   }
  2034. +
  2035. +   public void setTaskMgmtSession(TaskMgmtSession taskMgmtSession) {
  2036. +       this.taskMgmtSession = taskMgmtSession;
  2037. +   }
  2038. +
  2039. +   public void setSessionFactory(SessionFactory sessionFactory) {
  2040. +       this.persistenceServiceFactory.sessionFactory = sessionFactory;
  2041. +   }
  2042. +
  2043. +   public Transaction getTransaction() {
  2044. +       return transaction;
  2045. +   }
  2046. +
  2047. +   public void setTransaction(Transaction transaction) {
  2048. +       this.transaction = transaction;
  2049. +   }
  2050. +
  2051. +   public boolean isTransactionEnabled() {
  2052. +       return isTransactionEnabled;
  2053. +   }
  2054. +
  2055. +   public void setTransactionEnabled(boolean isTransactionEnabled) {
  2056. +       this.isTransactionEnabled = isTransactionEnabled;
  2057. +   }
  2058. +
  2059. +   private static Log log = LogFactory.getLog(DbPersistenceService.class);
  2060. +  
  2061. +   private class GetConnectionWork implements Work {
  2062. +      
  2063. +       private Connection connection = null;
  2064. +       /* (non-Javadoc)
  2065. +        * @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
  2066. +        */
  2067. +       @Override
  2068. +       public void execute(Connection arg0) throws SQLException {
  2069. +           this.connection = arg0;
  2070. +       }
  2071. +       /**
  2072. +        * @return the connection
  2073. +        */
  2074. +       public Connection getConnection() {
  2075. +           return connection;
  2076. +       }
  2077. +      
  2078. +   }
  2079.  }
  2080. Index: src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java
  2081. ===================================================================
  2082. --- src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java (revision 65983)
  2083. +++ src/main/java/org/jbpm/persistence/jta/JtaDbPersistenceService.java (revision 75353)
  2084. @@ -6,98 +6,106 @@
  2085.  
  2086.  import org.apache.commons.logging.Log;
  2087.  import org.apache.commons.logging.LogFactory;
  2088. -import org.hibernate.engine.SessionFactoryImplementor;
  2089. -import org.hibernate.util.JTAHelper;
  2090. +import org.hibernate.engine.spi.SessionFactoryImplementor;
  2091.  import org.jbpm.JbpmContext;
  2092.  import org.jbpm.JbpmException;
  2093.  import org.jbpm.persistence.db.DbPersistenceService;
  2094.  import org.jbpm.persistence.db.DbPersistenceServiceFactory;
  2095. +import javax.transaction.Status;
  2096.  
  2097.  public class JtaDbPersistenceService extends DbPersistenceService {
  2098.  
  2099. -  private static final long serialVersionUID = 1L;
  2100. -  
  2101. -  private static Log log = LogFactory.getLog(JbpmContext.class);  
  2102. -  
  2103. -  boolean isJtaTxCreated = false;
  2104. +   private static final long serialVersionUID = 1L;
  2105. +
  2106. +   private static Log log = LogFactory.getLog(JbpmContext.class);
  2107. +
  2108. +   boolean isJtaTxCreated = false;
  2109. +
  2110. +   public JtaDbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
  2111. +       super(persistenceServiceFactory);
  2112.  
  2113. -  public JtaDbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
  2114. -    super(persistenceServiceFactory);
  2115. -    
  2116. -    if (! isCurrentJtaTransactionAvailable()) {
  2117. -      beginJtaTransaction();
  2118. -      isJtaTxCreated = true;
  2119. -    }
  2120. -  }
  2121. +       if (!isCurrentJtaTransactionAvailable()) {
  2122. +           beginJtaTransaction();
  2123. +           isJtaTxCreated = true;
  2124. +       }
  2125. +   }
  2126.  
  2127. -  public void close() {
  2128. -    super.close();
  2129. +   public void close() {
  2130. +       super.close();
  2131.  
  2132. -    if (isJtaTxCreated) {
  2133. -      endJtaTransaction();
  2134. -    }
  2135. -  }
  2136. +       if (isJtaTxCreated) {
  2137. +           endJtaTransaction();
  2138. +       }
  2139. +   }
  2140.  
  2141. -  boolean isCurrentJtaTransactionAvailable() {
  2142. -    SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) persistenceServiceFactory.getSessionFactory();
  2143. -    return JTAHelper.isTransactionInProgress(sessionFactoryImplementor);
  2144. -  }
  2145. +   boolean isCurrentJtaTransactionAvailable() {
  2146. +       SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) persistenceServiceFactory
  2147. +               .getSessionFactory();
  2148. +       return sessionFactoryImplementor.getCurrentSession().getTransaction().isActive();
  2149. +   }
  2150.  
  2151. -  void beginJtaTransaction() {
  2152. -    try {
  2153. -       log.debug("start user JTA transaction");
  2154. -      getUserTransaction().begin();
  2155. -    } catch (Exception e) {
  2156. -      throw new JbpmException("couldn't start JTA transaction", e);
  2157. -    }
  2158. -  }
  2159. +   void beginJtaTransaction() {
  2160. +       try {
  2161. +           log.debug("start user JTA transaction");
  2162. +           getUserTransaction().begin();
  2163. +       } catch (Exception e) {
  2164. +           throw new JbpmException("couldn't start JTA transaction", e);
  2165. +       }
  2166. +   }
  2167.  
  2168. -  void endJtaTransaction() {
  2169. -    int status = -1;
  2170. -   log.debug("end user JTA transaction");
  2171. -    UserTransaction userTransaction = getUserTransaction();
  2172. -    try {
  2173. -      status = userTransaction.getStatus();
  2174. -    } catch (SystemException e) {
  2175. -      throw new JbpmException("couldn't get status for user transaction", e);
  2176. -    }
  2177. -    
  2178. -    boolean isRollback = JTAHelper.isRollback(status);
  2179. -    if (isRollback) {
  2180. -      log.debug("end jta transation with ROLLBACK");
  2181. -      try {
  2182. -        userTransaction.rollback();
  2183. -      } catch (Exception e) {
  2184. -        throw new JbpmException("couldn't rollback JTA transaction", e);
  2185. -      }
  2186. -    } else {
  2187. -      log.debug("end jta transation with COMMIT");
  2188. -      try {
  2189. -        userTransaction.commit();
  2190. -      } catch (Exception e) {
  2191. -        throw new JbpmException("couldn't commit JTA transaction", e);
  2192. -      }
  2193. -    }
  2194. -  }
  2195. -  
  2196. -  UserTransaction getUserTransaction() {
  2197. -    UserTransaction userTransaction = null;
  2198. -    if (userTransaction == null) {
  2199. -      String jndiName = "UserTransaction";
  2200. -      try {
  2201. -        userTransaction = (UserTransaction) new InitialContext().lookup(jndiName);
  2202. -      } catch (Exception e) {
  2203. -        throw new JbpmException("couldn't lookup UserTransaction in JNDI with name "+jndiName, e);
  2204. -      }
  2205. -    }
  2206. -    return userTransaction;
  2207. -  }
  2208. +   void endJtaTransaction() {
  2209. +       int status = -1;
  2210. +       log.debug("end user JTA transaction");
  2211. +       UserTransaction userTransaction = getUserTransaction();
  2212. +       try {
  2213. +           status = userTransaction.getStatus();
  2214. +       } catch (SystemException e) {
  2215. +           throw new JbpmException("couldn't get status for user transaction", e);
  2216. +       }
  2217.  
  2218. +       boolean isRollback = isRollback(status);
  2219. +       if (isRollback) {
  2220. +           log.debug("end jta transation with ROLLBACK");
  2221. +           try {
  2222. +               userTransaction.rollback();
  2223. +           } catch (Exception e) {
  2224. +               throw new JbpmException("couldn't rollback JTA transaction", e);
  2225. +           }
  2226. +       } else {
  2227. +           log.debug("end jta transation with COMMIT");
  2228. +           try {
  2229. +               userTransaction.commit();
  2230. +           } catch (Exception e) {
  2231. +               throw new JbpmException("couldn't commit JTA transaction", e);
  2232. +           }
  2233. +       }
  2234. +   }
  2235.  
  2236. -  public boolean isJtaTxCreated() {
  2237. -    return isJtaTxCreated;
  2238. -  }
  2239. -  public void setJtaTxCreated(boolean isJtaTxCreated) {
  2240. -    this.isJtaTxCreated = isJtaTxCreated;
  2241. -  }
  2242. +   UserTransaction getUserTransaction() {
  2243. +       UserTransaction userTransaction = null;
  2244. +       if (userTransaction == null) {
  2245. +           String jndiName = "UserTransaction";
  2246. +           try {
  2247. +               userTransaction = (UserTransaction) new InitialContext().lookup(jndiName);
  2248. +           } catch (Exception e) {
  2249. +               throw new JbpmException("couldn't lookup UserTransaction in JNDI with name " + jndiName, e);
  2250. +           }
  2251. +       }
  2252. +       return userTransaction;
  2253. +   }
  2254. +
  2255. +   public boolean isJtaTxCreated() {
  2256. +       return isJtaTxCreated;
  2257. +   }
  2258. +
  2259. +   public void setJtaTxCreated(boolean isJtaTxCreated) {
  2260. +       this.isJtaTxCreated = isJtaTxCreated;
  2261. +   }
  2262. +
  2263. +   private boolean isRollback(int status) {
  2264. +       return status == Status.STATUS_MARKED_ROLLBACK
  2265. +               || status == Status.STATUS_ROLLING_BACK
  2266. +               || status == Status.STATUS_ROLLEDBACK;
  2267. +
  2268. +   }
  2269.  }
  2270. Index: src/main/java/org/jbpm/db/hibernate/Converters.java
  2271. ===================================================================
  2272. --- src/main/java/org/jbpm/db/hibernate/Converters.java (revision 65983)
  2273. +++ src/main/java/org/jbpm/db/hibernate/Converters.java (revision 75353)
  2274. @@ -35,101 +35,105 @@
  2275.  import org.jbpm.util.ClassLoaderUtil;
  2276.  
  2277.  /**
  2278. - * provides access to the list of converters and ensures that the converter objects are unique.
  2279. + * provides access to the list of converters and ensures that the converter
  2280. + * objects are unique.
  2281.   */
  2282.  public abstract class Converters {
  2283. -  
  2284. -  static final int CONVERTERS_BY_CLASS_NAMES = 0;
  2285. -  static final int CONVERTERS_BY_DATABASE_ID = 1;
  2286. -  static final int CONVERTERS_IDS = 2;
  2287. +
  2288. +   static final int CONVERTERS_BY_CLASS_NAMES = 0;
  2289. +   static final int CONVERTERS_BY_DATABASE_ID = 1;
  2290. +   static final int CONVERTERS_IDS = 2;
  2291.  
  2292. -  static Map converterMapsMap = new HashMap();
  2293. -  
  2294. -  // public methods
  2295. +   static Map converterMapsMap = new HashMap();
  2296.  
  2297. -  public static Converter getConverterByClassName(String className) {
  2298. -    Converter converter = (Converter) getConvertersByClassNames().get(className);
  2299. -    if (converter==null) {
  2300. -      throw new JbpmException("converter '"+className+"' is not declared in jbpm.converter.properties");
  2301. -    }
  2302. -    return converter;
  2303. -  }
  2304. +   // public methods
  2305.  
  2306. -  public static Converter getConverterByDatabaseId(String converterDatabaseId) {
  2307. -    return (Converter) getConvertersByDatabaseId().get(converterDatabaseId);
  2308. -  }
  2309. +   public static Converter getConverterByClassName(String className) {
  2310. +       Converter converter = (Converter) getConvertersByClassNames().get(className);
  2311. +       if (converter == null) {
  2312. +           throw new JbpmException("converter '" + className + "' is not declared in jbpm.converter.properties");
  2313. +       }
  2314. +       return converter;
  2315. +   }
  2316.  
  2317. -  public static String getConverterId(Converter converter) {
  2318. -    return  (String) getConvertersIds().get(converter);
  2319. -  }
  2320. +   public static Converter getConverterByDatabaseId(String converterDatabaseId) {
  2321. +       return (Converter) getConvertersByDatabaseId().get(converterDatabaseId);
  2322. +   }
  2323.  
  2324. -  // maps class names to unique converter objects
  2325. -  static Map getConvertersByClassNames() {
  2326. -    return getConverterMaps()[CONVERTERS_BY_CLASS_NAMES];
  2327. -  }
  2328. +   public static String getConverterId(Converter converter) {
  2329. +       return (String) getConvertersIds().get(converter);
  2330. +   }
  2331.  
  2332. -  // maps converter database-id-strings to unique converter objects
  2333. -  static Map getConvertersByDatabaseId() {
  2334. -    return getConverterMaps()[CONVERTERS_BY_DATABASE_ID];
  2335. -  }
  2336. -  
  2337. -  // maps unique converter objects to their database-id-string
  2338. -  static Map getConvertersIds() {
  2339. -    return getConverterMaps()[CONVERTERS_IDS];
  2340. -  }
  2341. +   // maps class names to unique converter objects
  2342. +   static Map getConvertersByClassNames() {
  2343. +       return getConverterMaps()[CONVERTERS_BY_CLASS_NAMES];
  2344. +   }
  2345.  
  2346. -  static Map[] getConverterMaps() {
  2347. -    Map[] converterMaps = null;
  2348. -    synchronized(converterMapsMap) {
  2349. -      ObjectFactory objectFactory = JbpmConfiguration.Configs.getObjectFactory();
  2350. -      converterMaps = (Map[]) converterMapsMap.get(objectFactory);
  2351. -      if (converterMaps==null) {
  2352. -        converterMaps = createConverterMaps(objectFactory);
  2353. -        converterMapsMap.put(objectFactory, converterMaps);
  2354. -      }
  2355. -    }
  2356. -    return converterMaps;
  2357. -  }
  2358. +   // maps converter database-id-strings to unique converter objects
  2359. +   static Map getConvertersByDatabaseId() {
  2360. +       return getConverterMaps()[CONVERTERS_BY_DATABASE_ID];
  2361. +   }
  2362.  
  2363. -  static Map[] createConverterMaps(ObjectFactory objectFactory) {
  2364. -    Map[] converterMaps = new Map[3];
  2365. -    converterMaps[CONVERTERS_BY_CLASS_NAMES] = new HashMap();
  2366. -    converterMaps[CONVERTERS_BY_DATABASE_ID] = new HashMap();
  2367. -    converterMaps[CONVERTERS_IDS] = new HashMap();
  2368. +   // maps unique converter objects to their database-id-string
  2369. +   static Map getConvertersIds() {
  2370. +       return getConverterMaps()[CONVERTERS_IDS];
  2371. +   }
  2372.  
  2373. -    Map convertersByClassNames = converterMaps[CONVERTERS_BY_CLASS_NAMES];
  2374. -    Map convertersByDatabaseId = converterMaps[CONVERTERS_BY_DATABASE_ID];
  2375. -    Map convertersIds = converterMaps[CONVERTERS_IDS];
  2376. +   static Map[] getConverterMaps() {
  2377. +       Map[] converterMaps = null;
  2378. +       synchronized (converterMapsMap) {
  2379. +           ObjectFactory objectFactory = JbpmConfiguration.Configs.getObjectFactory();
  2380. +           converterMaps = (Map[]) converterMapsMap.get(objectFactory);
  2381. +           if (converterMaps == null) {
  2382. +               converterMaps = createConverterMaps(objectFactory);
  2383. +               converterMapsMap.put(objectFactory, converterMaps);
  2384. +           }
  2385. +       }
  2386. +       return converterMaps;
  2387. +   }
  2388.  
  2389. -    Properties converterProperties = null;
  2390. -    if (objectFactory.hasObject("resource.converter")) {
  2391. -      String resource = (String) objectFactory.createObject("resource.converter");
  2392. -      converterProperties = ClassLoaderUtil.getProperties(resource);
  2393. -    } else {
  2394. -      converterProperties = new Properties();
  2395. -    }
  2396. +   static Map[] createConverterMaps(ObjectFactory objectFactory) {
  2397. +       Map[] converterMaps = new Map[3];
  2398. +       converterMaps[CONVERTERS_BY_CLASS_NAMES] = new HashMap();
  2399. +       converterMaps[CONVERTERS_BY_DATABASE_ID] = new HashMap();
  2400. +       converterMaps[CONVERTERS_IDS] = new HashMap();
  2401.  
  2402. -    Iterator iter = converterProperties.keySet().iterator();
  2403. -    while (iter.hasNext()) {
  2404. -      String converterDatabaseId = (String) iter.next();
  2405. -      if (converterDatabaseId.length()!=1) throw new JbpmException("converter-ids must be of length 1 (to be stored in a char)");
  2406. -      if (convertersByDatabaseId.containsKey(converterDatabaseId)) throw new JbpmException("duplicate converter id : '"+converterDatabaseId+"'");
  2407. -      String converterClassName = converterProperties.getProperty(converterDatabaseId);
  2408. -      try {
  2409. -        Class converterClass = ClassLoaderUtil.loadClass(converterClassName);
  2410. -        Converter converter = (Converter) converterClass.newInstance();
  2411. -        log.debug("adding converter '"+converterDatabaseId+"', '"+converterClassName+"'");
  2412. -        convertersByClassNames.put(converterClassName, converter);
  2413. -        convertersByDatabaseId.put(converterDatabaseId, converter);
  2414. -        convertersIds.put(converter, converterDatabaseId);
  2415. -      } catch (Exception e) {
  2416. -        // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
  2417. -        log.debug("couldn't instantiate converter '"+converterClassName+"': "+e);
  2418. -      }
  2419. -    }
  2420. +       Map convertersByClassNames = converterMaps[CONVERTERS_BY_CLASS_NAMES];
  2421. +       Map convertersByDatabaseId = converterMaps[CONVERTERS_BY_DATABASE_ID];
  2422. +       Map convertersIds = converterMaps[CONVERTERS_IDS];
  2423.  
  2424. -    return converterMaps;
  2425. -  }
  2426. +       Properties converterProperties = null;
  2427. +       if (objectFactory.hasObject("resource.converter")) {
  2428. +           String resource = (String) objectFactory.createObject("resource.converter");
  2429. +           converterProperties = ClassLoaderUtil.getProperties(resource);
  2430. +       } else {
  2431. +           converterProperties = new Properties();
  2432. +       }
  2433.  
  2434. -  private static Log log = LogFactory.getLog(Converters.class);
  2435. +       Iterator iter = converterProperties.keySet().iterator();
  2436. +       while (iter.hasNext()) {
  2437. +           String converterDatabaseId = (String) iter.next();
  2438. +           if (converterDatabaseId.length() != 1)
  2439. +               throw new JbpmException("converter-ids must be of length 1 (to be stored in a char)");
  2440. +           if (convertersByDatabaseId.containsKey(converterDatabaseId))
  2441. +               throw new JbpmException("duplicate converter id : '" + converterDatabaseId + "'");
  2442. +           String converterClassName = converterProperties.getProperty(converterDatabaseId);
  2443. +           try {
  2444. +               Class converterClass = ClassLoaderUtil.loadClass(converterClassName);
  2445. +               Converter converter = (Converter) converterClass.newInstance();
  2446. +               log.debug("adding converter '" + converterDatabaseId + "', '" + converterClassName + "'");
  2447. +               convertersByClassNames.put(converterClassName, converter);
  2448. +               convertersByDatabaseId.put(converterDatabaseId, converter);
  2449. +               convertersIds.put(converter, converterDatabaseId);
  2450. +           } catch (Exception e) {
  2451. +               // NOTE that Error's are not caught because that might halt the
  2452. +               // JVM and mask the original Error.
  2453. +               log.debug("couldn't instantiate converter '" + converterClassName + "': " + e);
  2454. +           }
  2455. +       }
  2456. +
  2457. +       return converterMaps;
  2458. +   }
  2459. +
  2460. +   private static Log log = LogFactory.getLog(Converters.class);
  2461.  }
  2462. Index: src/main/java/org/jbpm/db/hibernate/StringMax.java
  2463. ===================================================================
  2464. --- src/main/java/org/jbpm/db/hibernate/StringMax.java  (revision 65983)
  2465. +++ src/main/java/org/jbpm/db/hibernate/StringMax.java  (revision 75353)
  2466. @@ -20,7 +20,7 @@
  2467.         ) {
  2468.        value = string.substring(0, length);
  2469.      }
  2470. -    super.set(st, value, index);
  2471. +    //super.set(st, value, index);
  2472.    }
  2473.  
  2474.    public void setParameterValues(Properties parameters) {
  2475. Index: src/main/java/org/jbpm/db/hibernate/ConverterEnumType.java
  2476. ===================================================================
  2477. --- src/main/java/org/jbpm/db/hibernate/ConverterEnumType.java  (revision 65983)
  2478. +++ src/main/java/org/jbpm/db/hibernate/ConverterEnumType.java  (revision 75353)
  2479. @@ -21,38 +21,101 @@
  2480.   */
  2481.  package org.jbpm.db.hibernate;
  2482.  
  2483. -import java.io.*;
  2484. -import java.sql.*;
  2485. +
  2486. +import java.io.Serializable;
  2487. +import java.sql.PreparedStatement;
  2488. +import java.sql.ResultSet;
  2489. +import java.sql.SQLException;
  2490. +import java.sql.Types;
  2491.  
  2492. -import org.hibernate.*;
  2493. -import org.hibernate.usertype.*;
  2494. -import org.jbpm.context.exe.*;
  2495. +import org.hibernate.HibernateException;
  2496. +import org.hibernate.engine.spi.SessionImplementor;
  2497. +import org.hibernate.usertype.UserType;
  2498. +import org.jbpm.context.exe.Converter;
  2499. +
  2500.  
  2501.  /**
  2502.   * is the hibernate UserType for storing converters as a char in the database.
  2503. - * The conversion can be found (and customized) in the file jbpm.converter.properties.
  2504. + * The conversion can be found (and customized) in the file
  2505. + * jbpm.converter.properties.
  2506.   */
  2507.  public class ConverterEnumType implements UserType {
  2508.  
  2509. -  static final int[] SQLTYPES = new int[]{Types.CHAR};
  2510. +   static final int[] SQLTYPES = new int[] { Types.CHAR };
  2511. +
  2512. +   public boolean equals(Object o1, Object o2) {
  2513. +       return (o1 == o2);
  2514. +   }
  2515. +
  2516. +   public int hashCode(Object o) throws HibernateException {
  2517. +       return o.hashCode();
  2518. +   }
  2519. +
  2520. +   public Object deepCopy(Object o) throws HibernateException {
  2521. +       return o;
  2522. +   }
  2523. +
  2524. +   public boolean isMutable() {
  2525. +       return false;
  2526. +   }
  2527. +
  2528. +   public Serializable disassemble(Object o) throws HibernateException {
  2529. +       return (Serializable) o;
  2530. +   }
  2531. +
  2532. +   public Object assemble(Serializable s, Object o) throws HibernateException {
  2533. +       return s;
  2534. +   }
  2535. +
  2536. +   public Object replace(Object original, Object target, Object owner) {
  2537. +       return target;
  2538. +   }
  2539. +
  2540. +   public int[] sqlTypes() {
  2541. +       return SQLTYPES;
  2542. +   }
  2543.  
  2544. -  public boolean equals(Object o1, Object o2) { return (o1==o2); }
  2545. -  public int hashCode(Object o) throws HibernateException { return o.hashCode(); }
  2546. -  public Object deepCopy(Object o) throws HibernateException { return o; }
  2547. -  public boolean isMutable() { return false; }
  2548. -  public Serializable disassemble(Object o) throws HibernateException { return (Serializable) o; }
  2549. -  public Object assemble(Serializable s, Object o) throws HibernateException { return s; }
  2550. -  public Object replace(Object original, Object target, Object owner) { return target; }
  2551. -  public int[] sqlTypes() { return SQLTYPES; }
  2552. -  public Class returnedClass() { return Converter.class; }
  2553. +   public Class returnedClass() {
  2554. +       return Converter.class;
  2555. +   }
  2556.  
  2557. -  public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException {
  2558. -    String converterDatabaseId = resultSet.getString(names[0]);
  2559. -    return Converters.getConverterByDatabaseId(converterDatabaseId);
  2560. -  }
  2561. +   public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException,
  2562. +           SQLException {
  2563. +       String converterDatabaseId = resultSet.getString(names[0]);
  2564. +       return Converters.getConverterByDatabaseId(converterDatabaseId);
  2565. +   }
  2566.  
  2567. -  public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
  2568. -    String converterDatabaseId = Converters.getConverterId((Converter) value);
  2569. -    preparedStatement.setString(index, converterDatabaseId);
  2570. -  }
  2571. +   public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException,
  2572. +           SQLException {
  2573. +       String converterDatabaseId = Converters.getConverterId((Converter) value);
  2574. +       preparedStatement.setString(index, converterDatabaseId);
  2575. +   }
  2576. +
  2577. +   /*
  2578. +    * (non-Javadoc)
  2579. +    *
  2580. +    * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet,
  2581. +    * java.lang.String[], org.hibernate.engine.spi.SessionImplementor,
  2582. +    * java.lang.Object)
  2583. +    */
  2584. +   @Override
  2585. +   public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner)
  2586. +           throws HibernateException, SQLException {
  2587. +       String converterDatabaseId = resultSet.getString(names[0]);
  2588. +       return Converters.getConverterByDatabaseId(converterDatabaseId);
  2589. +   }
  2590. +
  2591. +   /*
  2592. +    * (non-Javadoc)
  2593. +    *
  2594. +    * @see
  2595. +    * org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement,
  2596. +    * java.lang.Object, int, org.hibernate.engine.spi.SessionImplementor)
  2597. +    */
  2598. +   @Override
  2599. +   public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, SessionImplementor session)
  2600. +           throws HibernateException, SQLException {
  2601. +       String converterDatabaseId = Converters.getConverterId((Converter) value);
  2602. +       preparedStatement.setString(index, converterDatabaseId);
  2603. +   }
  2604.  }
  2605. Index: src/main/java/org/jbpm/db/JbpmSessionFactory.java
  2606. ===================================================================
  2607. --- src/main/java/org/jbpm/db/JbpmSessionFactory.java   (revision 65983)
  2608. +++ src/main/java/org/jbpm/db/JbpmSessionFactory.java   (revision 75353)
  2609. @@ -46,232 +46,241 @@
  2610.  import org.jbpm.util.ClassLoaderUtil;
  2611.  
  2612.  /**
  2613. - * creates JbpmSessions.
  2614. - * Obtain a JbpmSessionFactory with
  2615. + * creates JbpmSessions. Obtain a JbpmSessionFactory with
  2616. + *
  2617.   * <pre>
  2618.   * static JbpmSessionFactory jbpmSessionFactory = JbpmSessionFactory.buildJbpmSessionFactory();
  2619.   * </pre>
  2620. - * and store it somewhere static.  It takes quite some time to create a DbSessionFactory,
  2621. - * but you only have to do it once.  After that, creating DbSession's is really fast.
  2622.   *
  2623. - * @deprecated use {@link org.jbpm.tc.ContextBuilder} and {@link org.jbpm.tc.db.JbpmSessionContext} instead.
  2624. + * and store it somewhere static. It takes quite some time to create a
  2625. + * DbSessionFactory, but you only have to do it once. After that, creating
  2626. + * DbSession's is really fast.
  2627. + *
  2628. + * @deprecated use {@link org.jbpm.tc.ContextBuilder} and
  2629. + *             {@link org.jbpm.tc.db.JbpmSessionContext} instead.
  2630.   */
  2631.  public class JbpmSessionFactory implements Serializable {
  2632. -  
  2633. -  private static final long serialVersionUID = 1L;
  2634. +
  2635. +   private static final long serialVersionUID = 1L;
  2636. +
  2637. +   static String jndiName = getJndiName();
  2638.  
  2639. -  static String jndiName = getJndiName();
  2640. -  private static String getJndiName() {
  2641. -    String jndiName = null;
  2642. -    if (JbpmConfiguration.Configs.hasObject("jbpm.session.factory.jndi.name")) {
  2643. -      jndiName = JbpmConfiguration.Configs.getString("jbpm.session.factory.jndi.name");
  2644. -    }
  2645. -    return jndiName;
  2646. -  }
  2647. +   private static String getJndiName() {
  2648. +       String jndiName = null;
  2649. +       if (JbpmConfiguration.Configs.hasObject("jbpm.session.factory.jndi.name")) {
  2650. +           jndiName = JbpmConfiguration.Configs.getString("jbpm.session.factory.jndi.name");
  2651. +       }
  2652. +       return jndiName;
  2653. +   }
  2654.  
  2655. -  Configuration configuration = null;
  2656. -  SessionFactory sessionFactory = null;
  2657. -  Collection hibernatableLongIdClasses = null;
  2658. -  Collection hibernatableStringIdClasses = null;
  2659. -  JbpmSchema jbpmSchema = null;
  2660. -  
  2661. -  static JbpmSessionFactory instance = null;
  2662. -  /**
  2663. -   * a singleton is kept in JbpmSessionFactory as a convenient central location.
  2664. -   */
  2665. -  public static JbpmSessionFactory getInstance() {
  2666. -    if (instance==null) {
  2667. -      
  2668. -      // if there is a JNDI name configured
  2669. -      if (jndiName!=null) {
  2670. -        try {
  2671. -          // fetch the JbpmSessionFactory from JNDI
  2672. -          log.debug("fetching JbpmSessionFactory from '"+jndiName+"'");
  2673. -          InitialContext initialContext = new InitialContext();
  2674. -          Object o = initialContext.lookup(jndiName);
  2675. -          instance = (JbpmSessionFactory) PortableRemoteObject.narrow(o, JbpmSessionFactory.class);
  2676. -        } catch (Exception e) {
  2677. -          throw new JbpmException("couldn't fetch JbpmSessionFactory from jndi '"+jndiName+"'");
  2678. -        }
  2679. -        
  2680. -      } else { // else there is no JNDI name configured
  2681. -        // create a new default instance.
  2682. -        log.debug("building singleton JbpmSessionFactory");
  2683. -        instance = buildJbpmSessionFactory();
  2684. -      }
  2685. -    }
  2686. -    return instance;
  2687. -  }
  2688. -  
  2689. -  public JbpmSessionFactory(Configuration configuration) {
  2690. -    this( configuration, buildSessionFactory(configuration) );
  2691. -  }
  2692. +   Configuration configuration = null;
  2693. +   SessionFactory sessionFactory = null;
  2694. +   Collection hibernatableLongIdClasses = null;
  2695. +   Collection hibernatableStringIdClasses = null;
  2696. +   JbpmSchema jbpmSchema = null;
  2697.  
  2698. -  public JbpmSessionFactory(Configuration configuration, SessionFactory sessionFactory) {
  2699. -    this.configuration = configuration;
  2700. -    this.sessionFactory = sessionFactory;
  2701. -  }
  2702. -  
  2703. -  public static JbpmSessionFactory buildJbpmSessionFactory() {
  2704. -    return buildJbpmSessionFactory(getConfigResource());
  2705. -  }
  2706. +   static JbpmSessionFactory instance = null;
  2707.  
  2708. -  public static JbpmSessionFactory buildJbpmSessionFactory(String configResource) {
  2709. -    return buildJbpmSessionFactory(createConfiguration(configResource));
  2710. -  }
  2711. -  
  2712. -  public static JbpmSessionFactory buildJbpmSessionFactory(Configuration configuration) {
  2713. -    return new JbpmSessionFactory(configuration);
  2714. -  }
  2715. +   /**
  2716. +    * a singleton is kept in JbpmSessionFactory as a convenient central
  2717. +    * location.
  2718. +    */
  2719. +   public static JbpmSessionFactory getInstance() {
  2720. +       if (instance == null) {
  2721.  
  2722. -  private static String getConfigResource() {
  2723. -    return JbpmConfiguration.Configs.getString("resource.hibernate.cfg.xml");
  2724. -  }
  2725. +           // if there is a JNDI name configured
  2726. +           if (jndiName != null) {
  2727. +               try {
  2728. +                   // fetch the JbpmSessionFactory from JNDI
  2729. +                   log.debug("fetching JbpmSessionFactory from '" + jndiName + "'");
  2730. +                   InitialContext initialContext = new InitialContext();
  2731. +                   Object o = initialContext.lookup(jndiName);
  2732. +                   instance = (JbpmSessionFactory) PortableRemoteObject.narrow(o, JbpmSessionFactory.class);
  2733. +               } catch (Exception e) {
  2734. +                   throw new JbpmException("couldn't fetch JbpmSessionFactory from jndi '" + jndiName + "'");
  2735. +               }
  2736.  
  2737. -  public static Configuration createConfiguration() {
  2738. -    return createConfiguration(getConfigResource());
  2739. -  }
  2740. +           } else { // else there is no JNDI name configured
  2741. +               // create a new default instance.
  2742. +               log.debug("building singleton JbpmSessionFactory");
  2743. +               instance = buildJbpmSessionFactory();
  2744. +           }
  2745. +       }
  2746. +       return instance;
  2747. +   }
  2748.  
  2749. -  public static Configuration createConfiguration(String configResource) {
  2750. -    Configuration configuration = null;
  2751. -    // create the hibernate configuration
  2752. -    configuration = new Configuration();
  2753. -    if (configResource!=null) {
  2754. -      log.debug("using '"+configResource+"' as hibernate configuration for jbpm");
  2755. -      configuration.configure(configResource);
  2756. -    } else {
  2757. -      log.debug("using the default hibernate configuration file: hibernate.cfg.xml");
  2758. -      configuration.configure();
  2759. -    }
  2760. -    
  2761. -    // check if the properties in the hibernate.cfg.xml need to be overwritten by a separate properties file.
  2762. -    if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties")) {
  2763. -      String hibernatePropertiesResource = JbpmConfiguration.Configs.getString("resource.hibernate.properties");
  2764. -      Properties hibernateProperties = new Properties();
  2765. -      try {
  2766. -        hibernateProperties.load( ClassLoaderUtil.getStream(hibernatePropertiesResource) );
  2767. -      } catch (IOException e) {
  2768. -        e.printStackTrace();
  2769. -        throw new JbpmException("couldn't load the hibernate properties from resource '"+hibernatePropertiesResource+"'", e);
  2770. -      }
  2771. -      log.debug("overriding hibernate properties with "+ hibernateProperties);
  2772. -      configuration.setProperties(hibernateProperties);
  2773. -    }
  2774. -    
  2775. -    return configuration;
  2776. -  }
  2777. +   public JbpmSessionFactory(Configuration configuration) {
  2778. +       this(configuration, buildSessionFactory(configuration));
  2779. +   }
  2780.  
  2781. -  public static SessionFactory buildSessionFactory(Configuration configuration) {
  2782. -    SessionFactory sessionFactory = null;
  2783. -    // create the hibernate session factory
  2784. -    log.debug("building hibernate session factory");
  2785. -    sessionFactory = configuration.buildSessionFactory();
  2786. -    return sessionFactory;
  2787. -  }
  2788. +   public JbpmSessionFactory(Configuration configuration, SessionFactory sessionFactory) {
  2789. +       this.configuration = configuration;
  2790. +       this.sessionFactory = sessionFactory;
  2791. +   }
  2792.  
  2793. -  /**
  2794. -   * obtains a jdbc connection as specified in the hibernate configurations and
  2795. -   * creates a DbSession with it.
  2796. -   */
  2797. -  public JbpmSession openJbpmSession() {
  2798. -    return openJbpmSession((Connection)null);
  2799. -  }
  2800. +   public static JbpmSessionFactory buildJbpmSessionFactory() {
  2801. +       return buildJbpmSessionFactory(getConfigResource());
  2802. +   }
  2803.  
  2804. -  /**
  2805. -   * creates a DbSession around the given connection.  Note that you are
  2806. -   * responsible for closing the connection so closing the DbSession will
  2807. -   * not close the jdbc connection.
  2808. -   */
  2809. -  public JbpmSession openJbpmSession(Connection jdbcConnection) {
  2810. -    JbpmSession dbSession = null;
  2811. -    
  2812. -    try {
  2813. -      Session session = null;
  2814. -      
  2815. -      if ( jdbcConnection == null ) {
  2816. -        // use the hibernate properties in the nwsp.properties file to
  2817. -        // create a jdbc connection for the created hibernate session.
  2818. -        session = getSessionFactory().openSession();
  2819. -      } else {
  2820. -        // use the client provided jdbc connection in  
  2821. -        // the created hibernate session.
  2822. -        session = getSessionFactory().openSession(jdbcConnection);
  2823. -      }
  2824. -      
  2825. -      dbSession = new JbpmSession( this, session );
  2826. -      
  2827. -    } catch (HibernateException e) {
  2828. -      log.error( e );
  2829. -      throw new JbpmException( "couldn't create a hibernate persistence session", e );
  2830. -    }
  2831. -    return dbSession;
  2832. -  }
  2833. +   public static JbpmSessionFactory buildJbpmSessionFactory(String configResource) {
  2834. +       return buildJbpmSessionFactory(createConfiguration(configResource));
  2835. +   }
  2836.  
  2837. -  public JbpmSession openJbpmSession(Session session) {
  2838. -    return new JbpmSession(null, session);
  2839. -  }
  2840. +   public static JbpmSessionFactory buildJbpmSessionFactory(Configuration configuration) {
  2841. +       return new JbpmSessionFactory(configuration);
  2842. +   }
  2843.  
  2844. -  public JbpmSession openJbpmSessionAndBeginTransaction() {
  2845. -    JbpmSession dbSession = openJbpmSession((Connection)null);
  2846. -    dbSession.beginTransaction();
  2847. -    return dbSession;
  2848. -  }
  2849. -    
  2850. -  public SessionFactory getSessionFactory() {
  2851. -    return sessionFactory;
  2852. -  }
  2853. -  
  2854. -  public Configuration getConfiguration() {
  2855. -    return configuration;
  2856. -  }
  2857. -  
  2858. -  /**
  2859. -   * clears the process definitions from hibernate's second level cache.
  2860. -  public void evictCachedProcessDefinitions() {
  2861. -    sessionFactory.evict(ProcessDefinition.class);
  2862. -  }
  2863. -   */
  2864. +   private static String getConfigResource() {
  2865. +       return JbpmConfiguration.Configs.getString("resource.hibernate.cfg.xml");
  2866. +   }
  2867.  
  2868. -  /**
  2869. -   * checks if the given class is persistable with hibernate and has an id of type long.
  2870. -   */
  2871. -  public boolean isHibernatableWithLongId(Class clazz) {
  2872. -    if (hibernatableLongIdClasses==null) {
  2873. -      initHibernatableClasses();
  2874. -    }
  2875. -    return hibernatableLongIdClasses.contains(clazz);
  2876. -  }
  2877. +   public static Configuration createConfiguration() {
  2878. +       return createConfiguration(getConfigResource());
  2879. +   }
  2880.  
  2881. -  /**
  2882. -   * checks if the given class is persistable with hibernate and has an id of type string.
  2883. -   */
  2884. -  public boolean isHibernatableWithStringId(Class clazz) {
  2885. -    if (hibernatableStringIdClasses==null) {
  2886. -      initHibernatableClasses();
  2887. -    }
  2888. -    return hibernatableStringIdClasses.contains(clazz);
  2889. -  }
  2890. -  
  2891. -  public JbpmSchema getJbpmSchema() {
  2892. -    if (jbpmSchema==null) {
  2893. -      jbpmSchema = new JbpmSchema(configuration);
  2894. -    }
  2895. -    return jbpmSchema;
  2896. -  }
  2897. +   public static Configuration createConfiguration(String configResource) {
  2898. +       Configuration configuration = null;
  2899. +       // create the hibernate configuration
  2900. +       configuration = new Configuration();
  2901. +       if (configResource != null) {
  2902. +           log.debug("using '" + configResource + "' as hibernate configuration for jbpm");
  2903. +           configuration.configure(configResource);
  2904. +       } else {
  2905. +           log.debug("using the default hibernate configuration file: hibernate.cfg.xml");
  2906. +           configuration.configure();
  2907. +       }
  2908.  
  2909. -  void initHibernatableClasses() {
  2910. -    hibernatableLongIdClasses = new HashSet();
  2911. -    hibernatableStringIdClasses = new HashSet();
  2912. -    Iterator iter = configuration.getClassMappings();
  2913. -    while (iter.hasNext()) {
  2914. -      PersistentClass persistentClass = (PersistentClass) iter.next();
  2915. -      if (LongType.class==persistentClass.getIdentifier().getType().getClass()) {
  2916. -        hibernatableLongIdClasses.add( persistentClass.getMappedClass() );
  2917. -      } else if (StringType.class==persistentClass.getIdentifier().getType().getClass()) {
  2918. -        hibernatableStringIdClasses.add( persistentClass.getMappedClass() );
  2919. -      }
  2920. -    }
  2921. -  }
  2922. +       // check if the properties in the hibernate.cfg.xml need to be
  2923. +       // overwritten by a separate properties file.
  2924. +       if (JbpmConfiguration.Configs.hasObject("resource.hibernate.properties")) {
  2925. +           String hibernatePropertiesResource = JbpmConfiguration.Configs.getString("resource.hibernate.properties");
  2926. +           Properties hibernateProperties = new Properties();
  2927. +           try {
  2928. +               hibernateProperties.load(ClassLoaderUtil.getStream(hibernatePropertiesResource));
  2929. +           } catch (IOException e) {
  2930. +               e.printStackTrace();
  2931. +               throw new JbpmException("couldn't load the hibernate properties from resource '"
  2932. +                       + hibernatePropertiesResource + "'", e);
  2933. +           }
  2934. +           log.debug("overriding hibernate properties with " + hibernateProperties);
  2935. +           configuration.setProperties(hibernateProperties);
  2936. +       }
  2937.  
  2938. -  private static final Log log = LogFactory.getLog(JbpmSessionFactory.class);
  2939. +       return configuration;
  2940. +   }
  2941. +
  2942. +   public static SessionFactory buildSessionFactory(Configuration configuration) {
  2943. +       SessionFactory sessionFactory = null;
  2944. +       // create the hibernate session factory
  2945. +       log.debug("building hibernate session factory");
  2946. +       sessionFactory = configuration.buildSessionFactory();
  2947. +       return sessionFactory;
  2948. +   }
  2949. +
  2950. +   /**
  2951. +    * obtains a jdbc connection as specified in the hibernate configurations
  2952. +    * and creates a DbSession with it.
  2953. +    */
  2954. +   public JbpmSession openJbpmSession() {
  2955. +       return openJbpmSession((Connection) null);
  2956. +   }
  2957. +
  2958. +   /**
  2959. +    * creates a DbSession around the given connection. Note that you are
  2960. +    * responsible for closing the connection so closing the DbSession will not
  2961. +    * close the jdbc connection.
  2962. +    */
  2963. +   public JbpmSession openJbpmSession(Connection jdbcConnection) {
  2964. +       JbpmSession dbSession = null;
  2965. +
  2966. +       try {
  2967. +           Session session = null;
  2968. +
  2969. +           if (jdbcConnection == null) {
  2970. +               // use the hibernate properties in the nwsp.properties file to
  2971. +               // create a jdbc connection for the created hibernate session.
  2972. +               session = getSessionFactory().openSession();
  2973. +           } else {
  2974. +               // use the client provided jdbc connection in
  2975. +               // the created hibernate session.
  2976. +               session = getSessionFactory().openSession();
  2977. +           }
  2978. +
  2979. +           dbSession = new JbpmSession(this, session);
  2980. +
  2981. +       } catch (HibernateException e) {
  2982. +           log.error(e);
  2983. +           throw new JbpmException("couldn't create a hibernate persistence session", e);
  2984. +       }
  2985. +       return dbSession;
  2986. +   }
  2987. +
  2988. +   public JbpmSession openJbpmSession(Session session) {
  2989. +       return new JbpmSession(null, session);
  2990. +   }
  2991. +
  2992. +   public JbpmSession openJbpmSessionAndBeginTransaction() {
  2993. +       JbpmSession dbSession = openJbpmSession((Connection) null);
  2994. +       dbSession.beginTransaction();
  2995. +       return dbSession;
  2996. +   }
  2997. +
  2998. +   public SessionFactory getSessionFactory() {
  2999. +       return sessionFactory;
  3000. +   }
  3001. +
  3002. +   public Configuration getConfiguration() {
  3003. +       return configuration;
  3004. +   }
  3005. +
  3006. +   /**
  3007. +    * clears the process definitions from hibernate's second level cache.
  3008. +    * public void evictCachedProcessDefinitions() {
  3009. +    * sessionFactory.evict(ProcessDefinition.class); }
  3010. +    */
  3011. +
  3012. +   /**
  3013. +    * checks if the given class is persistable with hibernate and has an id of
  3014. +    * type long.
  3015. +    */
  3016. +   public boolean isHibernatableWithLongId(Class clazz) {
  3017. +       if (hibernatableLongIdClasses == null) {
  3018. +           initHibernatableClasses();
  3019. +       }
  3020. +       return hibernatableLongIdClasses.contains(clazz);
  3021. +   }
  3022. +
  3023. +   /**
  3024. +    * checks if the given class is persistable with hibernate and has an id of
  3025. +    * type string.
  3026. +    */
  3027. +   public boolean isHibernatableWithStringId(Class clazz) {
  3028. +       if (hibernatableStringIdClasses == null) {
  3029. +           initHibernatableClasses();
  3030. +       }
  3031. +       return hibernatableStringIdClasses.contains(clazz);
  3032. +   }
  3033. +
  3034. +   public JbpmSchema getJbpmSchema() {
  3035. +       if (jbpmSchema == null) {
  3036. +           jbpmSchema = new JbpmSchema(configuration);
  3037. +       }
  3038. +       return jbpmSchema;
  3039. +   }
  3040. +
  3041. +   void initHibernatableClasses() {
  3042. +       hibernatableLongIdClasses = new HashSet();
  3043. +       hibernatableStringIdClasses = new HashSet();
  3044. +       Iterator iter = configuration.getClassMappings();
  3045. +       while (iter.hasNext()) {
  3046. +           PersistentClass persistentClass = (PersistentClass) iter.next();
  3047. +           if (LongType.class == persistentClass.getIdentifier().getType().getClass()) {
  3048. +               hibernatableLongIdClasses.add(persistentClass.getMappedClass());
  3049. +           } else if (StringType.class == persistentClass.getIdentifier().getType().getClass()) {
  3050. +               hibernatableStringIdClasses.add(persistentClass.getMappedClass());
  3051. +           }
  3052. +       }
  3053. +   }
  3054. +
  3055. +   private static final Log log = LogFactory.getLog(JbpmSessionFactory.class);
  3056.  }
  3057. Index: src/main/java/org/jbpm/db/JbpmSchema.java
  3058. ===================================================================
  3059. --- src/main/java/org/jbpm/db/JbpmSchema.java   (revision 65983)
  3060. +++ src/main/java/org/jbpm/db/JbpmSchema.java   (revision 75353)
  3061. @@ -41,305 +41,373 @@
  3062.  
  3063.  import org.apache.commons.logging.Log;
  3064.  import org.apache.commons.logging.LogFactory;
  3065. +import org.hibernate.Session;
  3066. +import org.hibernate.SessionFactory;
  3067.  import org.hibernate.cfg.Configuration;
  3068.  import org.hibernate.cfg.Environment;
  3069. -import org.hibernate.connection.ConnectionProvider;
  3070. -import org.hibernate.connection.ConnectionProviderFactory;
  3071.  import org.hibernate.dialect.Dialect;
  3072. -import org.hibernate.engine.Mapping;
  3073. +import org.hibernate.engine.spi.Mapping;
  3074.  import org.hibernate.mapping.ForeignKey;
  3075.  import org.hibernate.mapping.Table;
  3076.  import org.hibernate.tool.hbm2ddl.SchemaExport;
  3077.  import org.hibernate.util.JDBCExceptionReporter;
  3078.  import org.jbpm.JbpmException;
  3079. +import org.hibernate.jdbc.Work;
  3080.  
  3081.  /**
  3082. - * utilities for the jBPM database schema.  
  3083. + * utilities for the jBPM database schema.
  3084.   */
  3085.  public class JbpmSchema implements Serializable {
  3086. -  
  3087. -  private static final long serialVersionUID = 1L;
  3088. +
  3089. +   private static final long serialVersionUID = 1L;
  3090. +
  3091. +   static final String JBPM_TABLE_PREFIX = "JBPM_";
  3092. +
  3093. +   Configuration configuration = null;
  3094. +   Properties properties = null;
  3095. +   Dialect dialect = null;
  3096. +   Mapping mapping = null;
  3097. +   String[] createSql = null;
  3098. +   String[] dropSql = null;
  3099. +   String[] cleanSql = null;
  3100. +
  3101. +   public JbpmSchema(Configuration configuration) {
  3102. +       this.configuration = configuration;
  3103. +       this.properties = configuration.getProperties();
  3104. +       this.dialect = Dialect.getDialect(properties);
  3105. +       try {
  3106. +           // get the mapping field via reflection :-(
  3107. +           Field mappingField = Configuration.class.getDeclaredField("mapping");
  3108. +           mappingField.setAccessible(true);
  3109. +           this.mapping = (Mapping) mappingField.get(configuration);
  3110. +       } catch (Exception e) {
  3111. +           throw new JbpmException("couldn't get the hibernate mapping", e);
  3112. +       }
  3113. +   }
  3114.  
  3115. -  static final String JBPM_TABLE_PREFIX = "JBPM_";
  3116. -  
  3117. -  Configuration configuration = null;
  3118. -  Properties properties = null;
  3119. -  Dialect dialect = null;
  3120. -  Mapping mapping = null;
  3121. -  String[] createSql = null;
  3122. -  String[] dropSql = null;
  3123. -  String[] cleanSql = null;
  3124. +   public String[] getCreateSql() {
  3125. +       if (createSql == null) {
  3126. +           createSql = configuration.generateSchemaCreationScript(dialect);
  3127. +       }
  3128. +       return createSql;
  3129. +   }
  3130.  
  3131. -  ConnectionProvider connectionProvider = null;
  3132. -  Connection connection = null;
  3133. -  Statement statement = null;
  3134. +   public String[] getDropSql() {
  3135. +       if (dropSql == null) {
  3136. +           dropSql = configuration.generateDropSchemaScript(dialect);
  3137. +       }
  3138. +       return dropSql;
  3139. +   }
  3140.  
  3141. -  public JbpmSchema(Configuration configuration) {
  3142. -    this.configuration = configuration;
  3143. -    this.properties = configuration.getProperties();
  3144. -    this.dialect = Dialect.getDialect(properties);
  3145. -    try {
  3146. -      // get the mapping field via reflection :-(
  3147. -      Field mappingField = Configuration.class.getDeclaredField("mapping");
  3148. -      mappingField.setAccessible(true);
  3149. -      this.mapping = (Mapping) mappingField.get(configuration);
  3150. -    } catch (Exception e) {
  3151. -      throw new JbpmException("couldn't get the hibernate mapping", e);
  3152. -    }
  3153. -  }
  3154. +   public String[] getCleanSql() {
  3155. +       if (cleanSql == null) {
  3156. +           // loop over all foreign key constraints
  3157. +           List dropForeignKeysSql = new ArrayList();
  3158. +           List createForeignKeysSql = new ArrayList();
  3159. +           Iterator iter = configuration.getTableMappings();
  3160. +           while (iter.hasNext()) {
  3161. +               Table table = (Table) iter.next();
  3162. +               if (table.isPhysicalTable()) {
  3163. +                   Iterator subIter = table.getForeignKeyIterator();
  3164. +                   while (subIter.hasNext()) {
  3165. +                       ForeignKey fk = (ForeignKey) subIter.next();
  3166. +                       if (fk.isPhysicalConstraint()) {
  3167. +                           // collect the drop foreign key constraint sql
  3168. +                           dropForeignKeysSql.add(fk.sqlDropString(dialect,
  3169. +                                   properties.getProperty(Environment.DEFAULT_CATALOG),
  3170. +                                   properties.getProperty(Environment.DEFAULT_SCHEMA)));
  3171. +                           // and collect the create foreign key constraint sql
  3172. +                           createForeignKeysSql.add(fk.sqlCreateString(dialect, mapping,
  3173. +                                   properties.getProperty(Environment.DEFAULT_CATALOG),
  3174. +                                   properties.getProperty(Environment.DEFAULT_SCHEMA)));
  3175. +                       }
  3176. +                   }
  3177. +               }
  3178. +           }
  3179.  
  3180. -  public String[] getCreateSql() {
  3181. -    if (createSql==null) {
  3182. -      createSql = configuration.generateSchemaCreationScript(dialect);
  3183. -    }
  3184. -    return createSql;
  3185. -  }
  3186. -  
  3187. -  public String[] getDropSql() {
  3188. -    if (dropSql==null) {
  3189. -      dropSql = configuration.generateDropSchemaScript(dialect);
  3190. -    }
  3191. -    return dropSql;
  3192. -  }
  3193. -  
  3194. -  public String[] getCleanSql() {
  3195. -    if (cleanSql==null) {
  3196. -      // loop over all foreign key constraints
  3197. -      List dropForeignKeysSql = new ArrayList();
  3198. -      List createForeignKeysSql = new ArrayList();
  3199. -      Iterator iter = configuration.getTableMappings();
  3200. -      while ( iter.hasNext() ) {
  3201. -        Table table = ( Table ) iter.next();
  3202. -        if ( table.isPhysicalTable() ) {
  3203. -          Iterator subIter = table.getForeignKeyIterator();
  3204. -          while ( subIter.hasNext() ) {
  3205. -            ForeignKey fk = ( ForeignKey ) subIter.next();
  3206. -            if ( fk.isPhysicalConstraint() ) {
  3207. -              // collect the drop foreign key constraint sql
  3208. -              dropForeignKeysSql.add( fk.sqlDropString(
  3209. -                  dialect,
  3210. -                  properties.getProperty(Environment.DEFAULT_CATALOG),
  3211. -                  properties.getProperty(Environment.DEFAULT_SCHEMA) ) );
  3212. -              // and collect the create foreign key constraint sql
  3213. -              createForeignKeysSql.add( fk.sqlCreateString(
  3214. -                  dialect,
  3215. -                  mapping,
  3216. -                  properties.getProperty(Environment.DEFAULT_CATALOG),
  3217. -                  properties.getProperty(Environment.DEFAULT_SCHEMA) ) );
  3218. -            }
  3219. -          }
  3220. -        }
  3221. -      }
  3222. +           List deleteSql = new ArrayList();
  3223. +           iter = configuration.getTableMappings();
  3224. +           while (iter.hasNext()) {
  3225. +               Table table = (Table) iter.next();
  3226. +               deleteSql.add("delete from " + table.getName());
  3227. +           }
  3228.  
  3229. -      List deleteSql = new ArrayList();
  3230. -      iter = configuration.getTableMappings();
  3231. -      while (iter.hasNext()) {
  3232. -        Table table = (Table) iter.next();
  3233. -        deleteSql.add("delete from "+table.getName());
  3234. -      }
  3235. +           // glue
  3236. +           // - drop foreign key constraints
  3237. +           // - delete contents of all tables
  3238. +           // - create foreign key constraints
  3239. +           // together to form the clean script
  3240. +           List cleanSqlList = new ArrayList();
  3241. +           cleanSqlList.addAll(dropForeignKeysSql);
  3242. +           cleanSqlList.addAll(deleteSql);
  3243. +           cleanSqlList.addAll(createForeignKeysSql);
  3244.  
  3245. -      // glue
  3246. -      //  - drop foreign key constraints
  3247. -      //  - delete contents of all tables
  3248. -      //  - create foreign key constraints
  3249. -      // together to form the clean script
  3250. -      List cleanSqlList = new ArrayList();
  3251. -      cleanSqlList.addAll(dropForeignKeysSql);
  3252. -      cleanSqlList.addAll(deleteSql);
  3253. -      cleanSqlList.addAll(createForeignKeysSql);
  3254. -      
  3255. -      cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
  3256. -    }
  3257. -    return cleanSql;
  3258. -  }
  3259. +           cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
  3260. +       }
  3261. +       return cleanSql;
  3262. +   }
  3263.  
  3264. -  public boolean hasJbpmTables() {
  3265. -    return (getJbpmTables().size()>0);
  3266. -  }
  3267. +   public boolean hasJbpmTables() {
  3268. +       return (getJbpmTables().size() > 0);
  3269. +   }
  3270.  
  3271. -  public List getJbpmTables() {
  3272. -    // delete all the data in the jbpm tables
  3273. -    List jbpmTableNames = new ArrayList();
  3274. -    try {
  3275. -      createConnection();
  3276. -      ResultSet resultSet = connection.getMetaData().getTables(null, null, null, null);
  3277. -      while(resultSet.next()) {
  3278. -        String tableName = resultSet.getString("TABLE_NAME");
  3279. -        if ( (tableName!=null)
  3280. -             && (tableName.length()>5)
  3281. -             && (JBPM_TABLE_PREFIX.equalsIgnoreCase(tableName.substring(0,5))) ) {
  3282. -          jbpmTableNames.add(tableName);
  3283. -        }
  3284. -      }
  3285. -    } catch (SQLException e) {
  3286. -      throw new JbpmException("couldn't get the jbpm table names");
  3287. -    } finally {
  3288. -      closeConnection();
  3289. -    }
  3290. -    return jbpmTableNames;
  3291. -  }
  3292. -  
  3293. -  public void dropSchema() {
  3294. -    execute( getDropSql() );
  3295. -  }
  3296. +   public List getJbpmTables() {
  3297. +       // delete all the data in the jbpm tables
  3298. +       List jbpmTableNames = new ArrayList();
  3299. +       Session session = null;
  3300. +       try {
  3301. +           SessionFactory sessionFactory = configuration.buildSessionFactory();
  3302. +           session = sessionFactory.openSession();
  3303. +           JBPMTablesWork work = new JBPMTablesWork();
  3304. +           session.doWork(work);
  3305. +           jbpmTableNames = work.getJbpmTableNames();
  3306. +       } catch (Exception e) {
  3307. +           throw new JbpmException("couldn't get the jbpm table names");
  3308. +       } finally {
  3309. +           if (session != null) {
  3310. +               session.close();
  3311. +           }
  3312. +       }
  3313. +       return jbpmTableNames;
  3314. +   }
  3315.  
  3316. -  public void createSchema() {
  3317. -    execute( getCreateSql() );
  3318. -  }
  3319. +   public void dropSchema() {
  3320. +       execute(getDropSql());
  3321. +   }
  3322.  
  3323. -  public void cleanSchema() {
  3324. -    execute( getCleanSql() );
  3325. -  }
  3326. +   public void createSchema() {
  3327. +       execute(getCreateSql());
  3328. +   }
  3329.  
  3330. -  public void saveSqlScripts(String dir, String prefix) {
  3331. -    try {
  3332. -      new File(dir).mkdirs();
  3333. -      saveSqlScript(dir+"/"+prefix+".drop.sql", getDropSql());
  3334. -      saveSqlScript(dir+"/"+prefix+".create.sql", getCreateSql());
  3335. -      saveSqlScript(dir+"/"+prefix+".clean.sql", getCleanSql());
  3336. -      new SchemaExport(configuration)
  3337. -        .setDelimiter(getSqlDelimiter())
  3338. -        .setOutputFile(dir+"/"+prefix+".drop.create.sql")
  3339. -        .create(true, false);
  3340. -    } catch (Exception e) {
  3341. -      throw new JbpmException("couldn't generate scripts", e);
  3342. -    }
  3343. -  }
  3344. +   public void cleanSchema() {
  3345. +       execute(getCleanSql());
  3346. +   }
  3347.  
  3348. -  public static void main(String[] args) {
  3349. -    try {
  3350. -      if ( (args==null) || (args.length==0) ) {
  3351. -        throw new IllegalArgumentException();
  3352. -      }
  3353. -      
  3354. -      String cmd = args[0];
  3355. -      
  3356. -      if ("create".equalsIgnoreCase(cmd)) {
  3357. -        Configuration configuration = createConfiguration(args, 1);
  3358. -        new JbpmSchema(configuration).createSchema();
  3359. -      } else if ("drop".equalsIgnoreCase(cmd)) {
  3360. -        Configuration configuration = createConfiguration(args, 1);
  3361. -        new JbpmSchema(configuration).dropSchema();
  3362. -      } else if ("clean".equalsIgnoreCase(cmd)) {
  3363. -        Configuration configuration = createConfiguration(args, 1);
  3364. -        new JbpmSchema(configuration).cleanSchema();
  3365. -      } else if ("scripts".equalsIgnoreCase(cmd)) {
  3366. -        Configuration configuration = createConfiguration(args, 3);
  3367. -        new JbpmSchema(configuration).saveSqlScripts(args[1], args[2]);
  3368. -      }
  3369. +   public void saveSqlScripts(String dir, String prefix) {
  3370. +       try {
  3371. +           new File(dir).mkdirs();
  3372. +           saveSqlScript(dir + "/" + prefix + ".drop.sql", getDropSql());
  3373. +           saveSqlScript(dir + "/" + prefix + ".create.sql", getCreateSql());
  3374. +           saveSqlScript(dir + "/" + prefix + ".clean.sql", getCleanSql());
  3375. +           new SchemaExport(configuration).setDelimiter(getSqlDelimiter())
  3376. +                   .setOutputFile(dir + "/" + prefix + ".drop.create.sql").create(true, false);
  3377. +       } catch (Exception e) {
  3378. +           throw new JbpmException("couldn't generate scripts", e);
  3379. +       }
  3380. +   }
  3381.  
  3382. -    } catch (IllegalArgumentException e) {
  3383. -      System.err.println("syntax: JbpmSchema create [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3384. -      System.err.println("syntax: JbpmSchema drop [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3385. -      System.err.println("syntax: JbpmSchema clean [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3386. -      System.err.println("syntax: JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3387. -    } catch (Exception e) {
  3388. -      e.printStackTrace();
  3389. -      throw new JbpmException(e);
  3390. -    }
  3391. -  }
  3392. -  
  3393. -  static Configuration createConfiguration(String[] args, int index) {
  3394. -    String hibernateCfgXml = (args.length>index ? args[index] : "hibernate.cfg.xml");
  3395. -    String hibernateProperties = (args.length>(index+1) ? args[index+1] : null);
  3396. -    
  3397. -    Configuration configuration = new Configuration();
  3398. -    configuration.configure(new File(hibernateCfgXml));
  3399. -    if (hibernateProperties!=null) {
  3400. -      try {
  3401. -        Properties properties = new Properties();
  3402. -        InputStream inputStream = new FileInputStream(hibernateProperties);
  3403. -        properties.load(inputStream);
  3404. -        configuration.setProperties(properties);
  3405. -      } catch (Exception e) {
  3406. -        e.printStackTrace();
  3407. -        throw new JbpmException("couldn't load hibernate configuration", e);
  3408. -      }
  3409. -    }
  3410. -    
  3411. -    return configuration;
  3412. -  }
  3413. +   public static void main(String[] args) {
  3414. +       try {
  3415. +           if ((args == null) || (args.length == 0)) {
  3416. +               throw new IllegalArgumentException();
  3417. +           }
  3418.  
  3419. -  void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException {
  3420. -    FileOutputStream fileOutputStream = new FileOutputStream(fileName);
  3421. -    try {
  3422. -      PrintStream printStream = new PrintStream(fileOutputStream);
  3423. -      for (int i=0; i<sql.length; i++) {
  3424. -        printStream.println(sql[i]+getSqlDelimiter());
  3425. -      }
  3426. -    } finally {
  3427. -      try {
  3428. -        fileOutputStream.close();
  3429. -      } catch (IOException e) {
  3430. -        e.printStackTrace();
  3431. -      }
  3432. -    }
  3433. -  }
  3434. +           String cmd = args[0];
  3435.  
  3436. -  public void execute(String[] sqls) {
  3437. -    String sql = null;
  3438. -    String showSqlText = properties.getProperty("hibernate.show_sql");
  3439. -    boolean showSql = ("true".equalsIgnoreCase(showSqlText));
  3440. +           if ("create".equalsIgnoreCase(cmd)) {
  3441. +               Configuration configuration = createConfiguration(args, 1);
  3442. +               new JbpmSchema(configuration).createSchema();
  3443. +           } else if ("drop".equalsIgnoreCase(cmd)) {
  3444. +               Configuration configuration = createConfiguration(args, 1);
  3445. +               new JbpmSchema(configuration).dropSchema();
  3446. +           } else if ("clean".equalsIgnoreCase(cmd)) {
  3447. +               Configuration configuration = createConfiguration(args, 1);
  3448. +               new JbpmSchema(configuration).cleanSchema();
  3449. +           } else if ("scripts".equalsIgnoreCase(cmd)) {
  3450. +               Configuration configuration = createConfiguration(args, 3);
  3451. +               new JbpmSchema(configuration).saveSqlScripts(args[1], args[2]);
  3452. +           }
  3453.  
  3454. -    try {
  3455. -      createConnection();
  3456. -      statement = connection.createStatement();
  3457. -      
  3458. -      for (int i=0; i<sqls.length; i++) {
  3459. -        sql = sqls[i];
  3460. -        
  3461. -        if (showSql) log.debug(sql);
  3462. -        statement.executeUpdate(sql);
  3463. -      }
  3464. -    
  3465. -    } catch (SQLException e) {
  3466. -      e.printStackTrace();
  3467. -      throw new JbpmException("couldn't execute sql '"+sql+"'", e);
  3468. -    } finally {
  3469. -      closeConnection();
  3470. -    }
  3471. -  }
  3472. +       } catch (IllegalArgumentException e) {
  3473. +           System.err.println("syntax: JbpmSchema create [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3474. +           System.err.println("syntax: JbpmSchema drop [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3475. +           System.err.println("syntax: JbpmSchema clean [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3476. +           System.err
  3477. +                   .println("syntax: JbpmSchema scripts <dir> <prefix> [<hibernate.cfg.xml> [<hibernate.properties>]]");
  3478. +       } catch (Exception e) {
  3479. +           e.printStackTrace();
  3480. +           throw new JbpmException(e);
  3481. +       }
  3482. +   }
  3483.  
  3484. -  void closeConnection() {
  3485. -    try {
  3486. -      if (statement!=null) statement.close();
  3487. -      if (connection!=null) {
  3488. -        JDBCExceptionReporter.logWarnings( connection.getWarnings() );
  3489. -        connection.clearWarnings();
  3490. -        connectionProvider.closeConnection(connection);
  3491. -        connectionProvider.close();
  3492. -      }
  3493. -    }
  3494. -    catch(Exception e) {
  3495. -      System.err.println( "Could not close connection" );
  3496. -      e.printStackTrace();
  3497. -    }
  3498. -  }
  3499. +   static Configuration createConfiguration(String[] args, int index) {
  3500. +       String hibernateCfgXml = (args.length > index ? args[index] : "hibernate.cfg.xml");
  3501. +       String hibernateProperties = (args.length > (index + 1) ? args[index + 1] : null);
  3502.  
  3503. -  void createConnection() throws SQLException {
  3504. -    connectionProvider = ConnectionProviderFactory.newConnectionProvider(properties);
  3505. -    connection = connectionProvider.getConnection();
  3506. -    if ( !connection.getAutoCommit() ) {
  3507. -      connection.commit();
  3508. -      connection.setAutoCommit(true);
  3509. -    }
  3510. -  }
  3511. +       Configuration configuration = new Configuration();
  3512. +       configuration.configure(new File(hibernateCfgXml));
  3513. +       if (hibernateProperties != null) {
  3514. +           try {
  3515. +               Properties properties = new Properties();
  3516. +               InputStream inputStream = new FileInputStream(hibernateProperties);
  3517. +               properties.load(inputStream);
  3518. +               configuration.setProperties(properties);
  3519. +           } catch (Exception e) {
  3520. +               e.printStackTrace();
  3521. +               throw new JbpmException("couldn't load hibernate configuration", e);
  3522. +           }
  3523. +       }
  3524.  
  3525. -  public Properties getProperties() {
  3526. -    return properties;
  3527. -  }
  3528. +       return configuration;
  3529. +   }
  3530.  
  3531. -  // sql delimiter ////////////////////////////////////////////////////////////
  3532. -  
  3533. -  static String sqlDelimiter = null;
  3534. -  synchronized String getSqlDelimiter() {
  3535. -    if (sqlDelimiter==null) {
  3536. -      sqlDelimiter = properties.getProperty("jbpm.sql.delimiter", ";");
  3537. -    }
  3538. -    return sqlDelimiter;
  3539. -  }
  3540. +   void saveSqlScript(String fileName, String[] sql) throws FileNotFoundException {
  3541. +       FileOutputStream fileOutputStream = new FileOutputStream(fileName);
  3542. +       try {
  3543. +           PrintStream printStream = new PrintStream(fileOutputStream);
  3544. +           for (int i = 0; i < sql.length; i++) {
  3545. +               printStream.println(sql[i] + getSqlDelimiter());
  3546. +           }
  3547. +       } finally {
  3548. +           try {
  3549. +               fileOutputStream.close();
  3550. +           } catch (IOException e) {
  3551. +               e.printStackTrace();
  3552. +           }
  3553. +       }
  3554. +   }
  3555.  
  3556. -  // logger ///////////////////////////////////////////////////////////////////
  3557. +   public void execute(String[] sqls) {
  3558. +       String sql = null;
  3559. +       String showSqlText = properties.getProperty("hibernate.show_sql");
  3560. +       boolean showSql = ("true".equalsIgnoreCase(showSqlText));      
  3561. +       Session session = null;
  3562. +       try {
  3563. +           SessionFactory sessionFactory = configuration.buildSessionFactory();
  3564. +           session = sessionFactory.openSession();
  3565. +           Work work = new SQLWork(sqls, showSql);
  3566. +           session.doWork(work);
  3567. +       } catch (Exception e) {
  3568. +           e.printStackTrace();
  3569. +           throw new JbpmException("couldn't execute sql '" + sql + "'", e);
  3570. +       } finally {
  3571. +           if (session!=null) {
  3572. +               session.close();
  3573. +           }
  3574. +       }
  3575. +   }
  3576.  
  3577. -  private static final Log log = LogFactory.getLog(JbpmSchema.class);
  3578. +   // void closeConnection() {
  3579. +   // try {
  3580. +   // if (statement!=null) statement.close();
  3581. +   // if (connection!=null) {
  3582. +   // JDBCExceptionReporter.logWarnings( connection.getWarnings() );
  3583. +   // connection.clearWarnings();
  3584. +   // connectionProvider.closeConnection(connection);
  3585. +   // connectionProvider.close();
  3586. +   // }
  3587. +   // }
  3588. +   // catch(Exception e) {
  3589. +   // System.err.println( "Could not close connection" );
  3590. +   // e.printStackTrace();
  3591. +   // }
  3592. +   // }
  3593. +   //
  3594. +   // void createConnection() throws SQLException {
  3595. +   // connectionProvider =
  3596. +   // ConnectionProviderFactory.newConnectionProvider(properties);
  3597. +   // connection = connectionProvider.getConnection();
  3598. +   // if ( !connection.getAutoCommit() ) {
  3599. +   // connection.commit();
  3600. +   // connection.setAutoCommit(true);
  3601. +   // }
  3602. +   // }
  3603. +
  3604. +   public Properties getProperties() {
  3605. +       return properties;
  3606. +   }
  3607. +
  3608. +   // sql delimiter
  3609. +   // ////////////////////////////////////////////////////////////
  3610. +
  3611. +   static String sqlDelimiter = null;
  3612. +
  3613. +   synchronized String getSqlDelimiter() {
  3614. +       if (sqlDelimiter == null) {
  3615. +           sqlDelimiter = properties.getProperty("jbpm.sql.delimiter", ";");
  3616. +       }
  3617. +       return sqlDelimiter;
  3618. +   }
  3619. +
  3620. +   // logger
  3621. +   // ///////////////////////////////////////////////////////////////////
  3622. +
  3623. +   private static final Log log = LogFactory.getLog(JbpmSchema.class);
  3624. +
  3625. +   // work definition for hibernate 4
  3626. +
  3627. +   private class JBPMTablesWork implements Work {
  3628. +
  3629. +       private final Log log = LogFactory.getLog(JBPMTablesWork.class);
  3630. +       private List jbpmTableNames = new ArrayList();
  3631. +
  3632. +       /*
  3633. +        * (non-Javadoc)
  3634. +        *
  3635. +        * @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
  3636. +        */
  3637. +       @Override
  3638. +       public void execute(Connection connection) throws SQLException {
  3639. +           try {
  3640. +               ResultSet resultSet = connection.getMetaData().getTables(null, null, null, null);
  3641. +               while (resultSet.next()) {
  3642. +                   String tableName = resultSet.getString("TABLE_NAME");
  3643. +                   if ((tableName != null) && (tableName.length() > 5)
  3644. +                           && (JBPM_TABLE_PREFIX.equalsIgnoreCase(tableName.substring(0, 5)))) {
  3645. +                       jbpmTableNames.add(tableName);
  3646. +                   }
  3647. +               }
  3648. +           } catch (SQLException e) {
  3649. +               log.error(e);
  3650. +               throw e;
  3651. +           }
  3652. +       }
  3653. +
  3654. +       /**
  3655. +        * @return the jbpmTableNames
  3656. +        */
  3657. +       public List getJbpmTableNames() {
  3658. +           return jbpmTableNames;
  3659. +       }
  3660. +
  3661. +   }
  3662. +
  3663. +   private class SQLWork implements Work {
  3664. +
  3665. +       private String[] script;
  3666. +       private boolean showSql;
  3667. +
  3668. +       public SQLWork(String[] sqls, boolean showSqlContent) {
  3669. +           super();
  3670. +           script = sqls;
  3671. +           showSql = showSqlContent;
  3672. +       }
  3673. +
  3674. +       /*
  3675. +        * (non-Javadoc)
  3676. +        *
  3677. +        * @see org.hibernate.jdbc.Work#execute(java.sql.Connection)
  3678. +        */
  3679. +       public void execute(Connection connection) throws SQLException {
  3680. +           try {
  3681. +               Statement statement = connection.createStatement();
  3682. +               try {
  3683. +                   for (int i = 0; i < script.length; i++) {
  3684. +                       String sql = script[i];
  3685. +                       if (showSql) {
  3686. +                           System.out.println(sql);
  3687. +                       }
  3688. +                       statement.executeUpdate(sql);
  3689. +                   }
  3690. +               } finally {
  3691. +                   statement.close();
  3692. +               }
  3693. +           } catch (SQLException e) {
  3694. +               throw new JbpmException("failed to execute sql", e);
  3695. +           } finally {
  3696. +               // sth todo
  3697. +           }
  3698. +       }
  3699. +
  3700. +   }
  3701.  }
  3702. Index: src/main/java/org/jbpm/db/compatibility/JbpmSchemaUpdate.java
  3703. ===================================================================
  3704. --- src/main/java/org/jbpm/db/compatibility/JbpmSchemaUpdate.java   (revision 65983)
  3705. +++ src/main/java/org/jbpm/db/compatibility/JbpmSchemaUpdate.java   (revision 75353)
  3706. @@ -17,11 +17,9 @@
  3707.  import org.hibernate.cfg.Configuration;
  3708.  import org.hibernate.cfg.NamingStrategy;
  3709.  import org.hibernate.cfg.Settings;
  3710. -import org.hibernate.connection.ConnectionProvider;
  3711. -import org.hibernate.connection.ConnectionProviderFactory;
  3712.  import org.hibernate.dialect.Dialect;
  3713.  import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
  3714. -import org.hibernate.util.ReflectHelper;
  3715. +//import org.hibernate.util.ReflectHelper;
  3716.  
  3717.  /**
  3718.   * This is a modified version of the hibernate tools schema update.
  3719. @@ -33,7 +31,6 @@
  3720.  public class JbpmSchemaUpdate {
  3721.  
  3722.     private static final Log log = LogFactory.getLog(JbpmSchemaUpdate.class);
  3723. -   private ConnectionProvider connectionProvider;
  3724.     private Configuration configuration;
  3725.     private Dialect dialect;
  3726.      private List exceptions;
  3727. @@ -48,14 +45,14 @@
  3728.         Properties props = new Properties();
  3729.         props.putAll( dialect.getDefaultProperties() );
  3730.         props.putAll(connectionProperties);
  3731. -       connectionProvider = ConnectionProviderFactory.newConnectionProvider(props);
  3732. +//     connectionProvider = ConnectionProviderFactory.newConnectionProvider(props);
  3733.          exceptions = new ArrayList();
  3734.     }
  3735.  
  3736.     public JbpmSchemaUpdate(Configuration cfg, Settings settings) throws HibernateException {
  3737.         this.configuration = cfg;
  3738. -       dialect = settings.getDialect();
  3739. -       connectionProvider = settings.getConnectionProvider();
  3740. +//     dialect = settings.getDialect();
  3741. +//     connectionProvider = settings.getConnectionProvider();
  3742.          exceptions = new ArrayList();
  3743.     }
  3744.    
  3745. @@ -85,9 +82,9 @@
  3746.                         doUpdate = false;
  3747.                     }
  3748.                     else if ( args[i].startsWith("--naming=") ) {
  3749. -                       cfg.setNamingStrategy(
  3750. -                           (NamingStrategy) ReflectHelper.classForName( args[i].substring(9) ).newInstance()
  3751. -                       );
  3752. +//                     cfg.setNamingStrategy(
  3753. +//                         (NamingStrategy) ReflectHelper.classForName( args[i].substring(9) ).newInstance()
  3754. +//                     );
  3755.                     }
  3756.                     else if (args[i].startsWith("--output=")) {
  3757.                         out = new File(args[i].substring(9));
  3758. @@ -144,7 +141,7 @@
  3759.             DatabaseMetadata meta;
  3760.             try {
  3761.                 log.info("fetching database metadata");
  3762. -               connection = connectionProvider.getConnection();
  3763. +//             connection = connectionProvider.getConnection();
  3764.                 if ( !connection.getAutoCommit() ) {
  3765.                     connection.commit();
  3766.                     connection.setAutoCommit(true);
  3767. @@ -201,7 +198,7 @@
  3768.                 if (stmt!=null) stmt.close();
  3769.                 if (!autoCommitWasEnabled) connection.setAutoCommit(false);
  3770.                 if (connection!=null) connection.close();
  3771. -               if (connectionProvider!=null) connectionProvider.close();
  3772. +//             if (connectionProvider!=null) connectionProvider.close();
  3773.             }
  3774.             catch (Exception e) {
  3775.                  exceptions.add(e);
  3776. Index: src/main/java/org/jbpm/db/JbpmSession.java
  3777. ===================================================================
  3778. --- src/main/java/org/jbpm/db/JbpmSession.java  (revision 65983)
  3779. +++ src/main/java/org/jbpm/db/JbpmSession.java  (revision 75353)
  3780. @@ -98,15 +98,15 @@
  3781.      return jbpmSessionFactory;
  3782.    }
  3783.  
  3784. -  public Connection getConnection() {
  3785. -    try {
  3786. -      return session.connection();
  3787. -    } catch (Exception e) {
  3788. -      log.error(e);
  3789. -      handleException();
  3790. -      throw new JbpmException( "couldn't get the jdbc connection from hibernate", e );
  3791. -    }
  3792. -  }
  3793. +//  public Connection getConnection() {
  3794. +//    try {
  3795. +//      return session.connection();
  3796. +//    } catch (Exception e) {
  3797. +//      log.error(e);
  3798. +//      handleException();
  3799. +//      throw new JbpmException( "couldn't get the jdbc connection from hibernate", e );
  3800. +//    }
  3801. +//  }
  3802.  
  3803.    public Session getSession() {
  3804.      return session;
  3805. Index: src/main/java/org/jbpm/graph/node/Join.java
  3806. ===================================================================
  3807. --- src/main/java/org/jbpm/graph/node/Join.java (revision 65983)
  3808. +++ src/main/java/org/jbpm/graph/node/Join.java (revision 75353)
  3809. @@ -110,7 +110,7 @@
  3810.          if (session!=null) {
  3811.            LockMode lockMode = LockMode.FORCE;
  3812.            if (parentLockMode!=null) {
  3813. -            lockMode = LockMode.parse(parentLockMode);
  3814. +            lockMode = LockMode.valueOf(parentLockMode);
  3815.            }
  3816.            log.debug("forcing version increment on parent token "+parentToken);
  3817.            session.lock(parentToken, lockMode);
  3818. Index: src/main/resources/org/jbpm/context/exe/TokenVariableMap.hbm.xml
  3819. ===================================================================
  3820. --- src/main/resources/org/jbpm/context/exe/TokenVariableMap.hbm.xml    (revision 65983)
  3821. +++ src/main/resources/org/jbpm/context/exe/TokenVariableMap.hbm.xml    (revision 75353)
  3822. @@ -1,8 +1,7 @@
  3823.  <?xml version="1.0"?>
  3824.  
  3825. -<!DOCTYPE hibernate-mapping PUBLIC
  3826. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3827. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3828. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3829. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3830.  
  3831.  <hibernate-mapping auto-import="false" default-access="field">
  3832.    <class name="org.jbpm.context.exe.TokenVariableMap"
  3833. Index: src/main/resources/org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml
  3834. ===================================================================
  3835. --- src/main/resources/org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml (revision 65983)
  3836. +++ src/main/resources/org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml (revision 75353)
  3837. @@ -1,8 +1,7 @@
  3838.  <?xml version="1.0"?>
  3839.  
  3840. -<!DOCTYPE hibernate-mapping PUBLIC
  3841. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3842. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3843. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3844. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3845.  
  3846.  <hibernate-mapping auto-import="false" default-access="field">
  3847.    <subclass name="org.jbpm.context.exe.variableinstance.StringInstance"
  3848. Index: src/main/resources/org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml
  3849. ===================================================================
  3850. --- src/main/resources/org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml    (revision 65983)
  3851. +++ src/main/resources/org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml    (revision 75353)
  3852. @@ -1,8 +1,7 @@
  3853.  <?xml version="1.0"?>
  3854.  
  3855. -<!DOCTYPE hibernate-mapping PUBLIC
  3856. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3857. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3858. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3859. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3860.  
  3861.  <hibernate-mapping auto-import="false" default-access="field">
  3862.    <subclass name="org.jbpm.context.exe.variableinstance.HibernateStringInstance"
  3863. Index: src/main/resources/org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml
  3864. ===================================================================
  3865. --- src/main/resources/org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml (revision 65983)
  3866. +++ src/main/resources/org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml (revision 75353)
  3867. @@ -1,8 +1,7 @@
  3868.  <?xml version="1.0"?>
  3869.  
  3870. -<!DOCTYPE hibernate-mapping PUBLIC
  3871. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3872. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3873. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3874. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3875.  
  3876.  <hibernate-mapping auto-import="false" default-access="field">
  3877.    <subclass name="org.jbpm.context.exe.variableinstance.DoubleInstance"
  3878. Index: src/main/resources/org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml
  3879. ===================================================================
  3880. --- src/main/resources/org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml   (revision 65983)
  3881. +++ src/main/resources/org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml   (revision 75353)
  3882. @@ -1,8 +1,7 @@
  3883.  <?xml version="1.0"?>
  3884.  
  3885. -<!DOCTYPE hibernate-mapping PUBLIC
  3886. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3887. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3888. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3889. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3890.  
  3891.  <hibernate-mapping auto-import="false" default-access="field">
  3892.    <subclass name="org.jbpm.context.exe.variableinstance.NullInstance"
  3893. Index: src/main/resources/org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml
  3894. ===================================================================
  3895. --- src/main/resources/org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml   (revision 65983)
  3896. +++ src/main/resources/org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml   (revision 75353)
  3897. @@ -1,8 +1,7 @@
  3898.  <?xml version="1.0"?>
  3899.  
  3900. -<!DOCTYPE hibernate-mapping PUBLIC
  3901. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3902. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3903. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3904. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3905.  
  3906.  <hibernate-mapping auto-import="false" default-access="field">
  3907.    <subclass name="org.jbpm.context.exe.variableinstance.DateInstance"
  3908. Index: src/main/resources/org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml
  3909. ===================================================================
  3910. --- src/main/resources/org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml   (revision 65983)
  3911. +++ src/main/resources/org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml   (revision 75353)
  3912. @@ -1,8 +1,7 @@
  3913.  <?xml version="1.0"?>
  3914.  
  3915. -<!DOCTYPE hibernate-mapping PUBLIC
  3916. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3917. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3918. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3919. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3920.  
  3921.  <hibernate-mapping auto-import="false" default-access="field">
  3922.    <subclass name="org.jbpm.context.exe.variableinstance.LongInstance"
  3923. Index: src/main/resources/org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml
  3924. ===================================================================
  3925. --- src/main/resources/org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml  (revision 65983)
  3926. +++ src/main/resources/org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml  (revision 75353)
  3927. @@ -1,8 +1,7 @@
  3928.  <?xml version="1.0"?>
  3929.  
  3930. -<!DOCTYPE hibernate-mapping PUBLIC
  3931. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3932. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3933. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3934. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3935.  
  3936.  <hibernate-mapping auto-import="false" default-access="field">
  3937.    <subclass name="org.jbpm.context.exe.variableinstance.HibernateLongInstance"
  3938. Index: src/main/resources/org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml
  3939. ===================================================================
  3940. --- src/main/resources/org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml  (revision 65983)
  3941. +++ src/main/resources/org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml  (revision 75353)
  3942. @@ -1,8 +1,7 @@
  3943.  <?xml version="1.0"?>
  3944.  
  3945. -<!DOCTYPE hibernate-mapping PUBLIC
  3946. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3947. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3948. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3949. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3950.  
  3951.  <hibernate-mapping auto-import="false" default-access="field">
  3952.    <subclass name="org.jbpm.context.exe.variableinstance.ByteArrayInstance"
  3953. Index: src/main/resources/org/jbpm/context/exe/variableinstance/JcrNodeInstance.hbm.xml
  3954. ===================================================================
  3955. --- src/main/resources/org/jbpm/context/exe/variableinstance/JcrNodeInstance.hbm.xml    (revision 65983)
  3956. +++ src/main/resources/org/jbpm/context/exe/variableinstance/JcrNodeInstance.hbm.xml    (revision 75353)
  3957. @@ -1,8 +1,7 @@
  3958.  <?xml version="1.0"?>
  3959.  
  3960. -<!DOCTYPE hibernate-mapping PUBLIC
  3961. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3962. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3963. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3964. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3965.  
  3966.  <hibernate-mapping auto-import="false" default-access="field">
  3967.    <subclass name="org.jbpm.context.exe.variableinstance.JcrNodeInstance"
  3968. Index: src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml
  3969. ===================================================================
  3970. --- src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml (revision 65983)
  3971. +++ src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml (revision 75353)
  3972. @@ -1,8 +1,7 @@
  3973.  <?xml version="1.0"?>
  3974.  
  3975. -<!DOCTYPE hibernate-mapping PUBLIC
  3976. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3977. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3978. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3979. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3980.  
  3981.  <hibernate-mapping auto-import="false" default-access="field">
  3982.  
  3983. Index: src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml
  3984. ===================================================================
  3985. --- src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml    (revision 65983)
  3986. +++ src/main/resources/org/jbpm/context/exe/VariableInstance.hbm.xml    (revision 75353)
  3987. @@ -1,8 +1,7 @@
  3988.  <?xml version="1.0"?>
  3989.  
  3990. -<!DOCTYPE hibernate-mapping PUBLIC
  3991. -    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3992. -    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3993. +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  3994. +"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
  3995.  
  3996.  <hibernate-mapping auto-import="false" default-access="field">
  3997.    <class name="org.jbpm.context.exe.VariableInstance"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement