[jbpm-commits] JBoss JBPM SVN: r5472 - in jbpm4/trunk/modules: test-cfg/src/test/java/org/jbpm/test and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Aug 12 10:09:10 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-08-12 10:09:09 -0400 (Wed, 12 Aug 2009)
New Revision: 5472

Added:
   jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/
   jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/HibernateStringIdTest.java
   jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/Order.java
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.hibernate.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml
   jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/order.hbm.xml
Modified:
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
Log:
JBPM-2474 Process variables of type hibernate-long-id/hibernate-string-id don't work

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2009-08-12 13:45:20 UTC (rev 5471)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2009-08-12 14:09:09 UTC (rev 5472)
@@ -156,15 +156,15 @@
   
   <subclass name="org.jbpm.pvm.internal.type.variable.HibernateLongVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="hib-long">
     <any name="hibernatable" id-type="long">
+      <column name="CLASSNAME_"/>
       <column name="LONG_VALUE_"/>
-      <column name="CLASSNAME_"/>
     </any>
   </subclass>
   
   <subclass name="org.jbpm.pvm.internal.type.variable.HibernateStringVariable" extends="org.jbpm.pvm.internal.type.Variable" discriminator-value="hib-string">
     <any name="hibernatable" id-type="string">
+      <column name="CLASSNAME_"/>
       <column name="STRING_VALUE_"/>
-      <column name="CLASSNAME_"/>
     </any>
   </subclass>
   

Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/HibernateStringIdTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/HibernateStringIdTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/HibernateStringIdTest.java	2009-08-12 14:09:09 UTC (rev 5472)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.hibernatestringid;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.classic.Session;
+import org.hibernate.context.ThreadLocalSessionContext;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmCustomCfgTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateStringIdTest extends JbpmCustomCfgTestCase {
+  
+  protected void deleteRegisteredDeployments() {
+    SessionFactory sessionFactory = processEngine.get(SessionFactory.class);
+    
+    Session session = sessionFactory.openSession();
+    Transaction transaction = session.beginTransaction();
+    ThreadLocalSessionContext.bind(session);
+
+    try {
+      super.deleteRegisteredDeployments();
+      
+      List<Order> orders = session.createQuery("from "+Order.class.getName()).list();
+      for (Order order: orders) {
+        session.delete(order);
+      }
+
+    } finally {
+      ThreadLocalSessionContext.unbind(sessionFactory);
+      transaction.commit();
+      session.close();
+    }
+  }
+
+  public void testHibernateStringId() {
+    SessionFactory sessionFactory = processEngine.get(SessionFactory.class);
+    
+    Session session = sessionFactory.openSession();
+    Transaction transaction = session.beginTransaction();
+    ThreadLocalSessionContext.bind(session);
+
+    try {
+      deployJpdlXmlString(
+        "<process name='HibernateStringId'>" +
+        "  <start>" +
+        "    <transition to='a' />" +
+        "  </start>" +
+        "  <state name='a' />" +
+        "</process>"
+      );
+    } finally {
+      ThreadLocalSessionContext.unbind(sessionFactory);
+      transaction.commit();
+      session.close();
+    }
+
+    String processInstanceId;
+    
+    session = sessionFactory.openSession();
+    transaction = session.beginTransaction();
+    ThreadLocalSessionContext.bind(session);
+
+    try {
+      Order order = new Order("order1");
+      order.setClient("Contador");
+      order.setProduct("Shampoo");
+
+      session.save(order);
+      session.flush();
+      
+      Map<String, Object> variables = new HashMap<String, Object>();
+      variables.put("order", order);
+
+      ProcessInstance processInstance = executionService.startProcessInstanceByKey("HibernateStringId", variables);
+      processInstanceId = processInstance.getId();
+      
+    } finally {
+      ThreadLocalSessionContext.unbind(sessionFactory);
+      transaction.commit();
+      session.close();
+    }
+
+    session = sessionFactory.openSession();
+    transaction = session.beginTransaction();
+    ThreadLocalSessionContext.bind(session);
+    
+    try {
+      Order order = (Order) executionService.getVariable(processInstanceId, "order");
+      assertNotNull(order);
+      assertEquals("Contador", order.getClient());
+      assertEquals("Shampoo", order.getProduct());
+    } finally {
+      ThreadLocalSessionContext.unbind(sessionFactory);
+      transaction.commit();
+      session.close();
+    }
+  }
+}


Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/HibernateStringIdTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/Order.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/Order.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/Order.java	2009-08-12 14:09:09 UTC (rev 5472)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.hibernatestringid;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Order {
+
+  String id;
+  
+  String client;
+  String product;
+  
+  protected Order() {
+  }
+  
+  public Order(String id) {
+    this.id = id;
+  }
+
+  public String getClient() {
+    return client;
+  }
+  public void setClient(String client) {
+    this.client = client;
+  }
+  public String getProduct() {
+    return product;
+  }
+  public void setProduct(String product) {
+    this.product = product;
+  }
+  public String getId() {
+    return id;
+  }
+}


Property changes on: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/hibernatestringid/Order.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml	                        (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml	2009-08-12 14:09:09 UTC (rev 5472)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+  <import resource="jbpm.businesscalendar.cfg.xml" />
+  <import resource="org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml" />
+  <import resource="jbpm.jpdl.cfg.xml" />
+  <import resource="jbpm.identity.cfg.xml" />
+
+  <process-engine-context>
+  
+    <repository-service />
+    <repository-cache />
+    <execution-service />
+    <history-service />
+    <management-service />
+    <identity-service />
+    <task-service />
+
+    <hibernate-configuration>
+      <cfg resource="org/jbpm/test/hibernatestringid/jbpm.hibernate.cfg.xml" />     
+    </hibernate-configuration>
+
+    <hibernate-session-factory />
+
+    <script-manager default-expression-language="juel"
+                    default-script-language="juel">
+      <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
+    </script-manager>
+    
+    <id-generator />
+    <types resource="jbpm.variable.types.xml" />
+
+    <address-resolver />
+
+    <mail-template name='task-notification'>
+      <to users="${task.assignee}"/>
+      <subject>${task.name}</subject>
+      <text><![CDATA[Hi ${task.assignee},
+Task "${task.name}" has been assigned to you.
+${task.description}
+
+Sent by JBoss jBPM
+]]></text>
+    </mail-template>
+  
+    <mail-template name='task-reminder'>
+      <to users="${task.assignee}"/>
+      <subject>${task.name}</subject>
+      <text><![CDATA[Hey ${task.assignee},
+Do not forget about task "${task.name}".
+${task.description}
+
+Sent by JBoss jBPM
+]]></text>
+    </mail-template>
+  
+  </process-engine-context>
+
+  <transaction-context>
+    <repository-session />
+    <db-session />
+    
+    <message-session />
+    <timer-session />
+    <history-session />
+    <mail-session>
+      <mail-server>
+        <session-properties resource="jbpm.mail.properties" />
+      </mail-server>
+    </mail-session>
+  </transaction-context>
+
+</jbpm-configuration>


Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.cfg.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.hibernate.cfg.xml	2009-08-12 14:09:09 UTC (rev 5472)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+  <session-factory>
+  
+     <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+     <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+     <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+     <property name="hibernate.connection.username">sa</property>
+     <property name="hibernate.connection.password"></property>
+     <property name="hibernate.hbm2ddl.auto">create-drop</property>
+     <property name="hibernate.format_sql">true</property>
+     
+     <!-- Enable Hibernate's automatic session context management -->
+     <property name="current_session_context_class">thread</property>
+     
+     <mapping resource="jbpm.repository.hbm.xml" />
+     <mapping resource="jbpm.execution.hbm.xml" />
+     <mapping resource="jbpm.history.hbm.xml" />
+     <mapping resource="jbpm.task.hbm.xml" />
+     <mapping resource="jbpm.identity.hbm.xml" />
+
+     <mapping resource="org/jbpm/test/hibernatestringid/order.hbm.xml" />
+     
+  </session-factory>
+</hibernate-configuration>


Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml	                        (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml	2009-08-12 14:09:09 UTC (rev 5472)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+  <process-engine-context>
+    <command-service>
+      <retry-interceptor />
+      <environment-interceptor />
+    </command-service>
+  </process-engine-context>
+
+  <transaction-context>
+    <hibernate-session current="true" />
+  </transaction-context>
+
+</jbpm-configuration>


Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/jbpm.tx.hibernate.cfg.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/order.hbm.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/order.hbm.xml	                        (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/order.hbm.xml	2009-08-12 14:09:09 UTC (rev 5472)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping default-access="field">
+
+  <!-- ### Deployment ##################################################### -->
+  <class name="org.jbpm.test.hibernatestringid.Order" table="ORDERS">
+
+    <id name="id">
+      <generator class="assigned" />
+    </id>
+
+    <property name="client" />
+    <property name="product" />
+
+  </class>
+
+</hibernate-mapping>


Property changes on: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatestringid/order.hbm.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the jbpm-commits mailing list