[JBoss Seam] - Entity association reflection issue
by nevilleharrison
Hi,
I have generated an application using seam-gen (via the JBoss Tools) to an SQL server database that contains two tables: S_Application and S_Application_History. The S_Application_History table has a foreign key mapping to S_Application.
Seam-gen creates corresponding SApplication, SApplicationHome, SApplicationHistory and SApplicationHistoryHome objects.
The generated application fails with "PropertyNotFound" errors which seem to be related to the generated method names. Specifically, we have foundthat the double initial capital letter causes problems.
For example, when trying to traverse the association such as #{sApplicationHistoryHome.instance.sApplication} a "PropertyNotFoundException" occurs. This traversal corresponds to sApplicationHistoryHome.getInstance().getSApplication().
In this example, if we change "getSApplication" to "getApp" (and change the corresponding code in the other relevant places) then the traversal works OK. ie the method name does not have two consective capital letters.
This seems to be a bug.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110431#4110431
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110431
18 years, 4 months
[JBoss jBPM] - Re: TaskInstance and ProcessInstance not ending
by Sowmya Yellamilli
ok i'll get back to u with my unit test ...
meanwhile, i am not able to understand why websale also behaved the same way...websale unit test which i executed was like this:
/*
| * 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.websale;
|
| import java.util.HashMap;
| import java.util.List;
| import java.util.Map;
|
| import junit.framework.TestCase;
|
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.JbpmContext;
| import org.jbpm.context.exe.ContextInstance;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.identity.Entity;
| import org.jbpm.identity.hibernate.IdentitySession;
| import org.jbpm.identity.xml.IdentityXmlParser;
| import org.jbpm.persistence.db.DbPersistenceServiceFactory;
| import org.jbpm.svc.Services;
| import org.jbpm.taskmgmt.exe.TaskInstance;
| import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
|
| public class WebsaleTest extends TestCase {
|
| JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
| DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration.getServiceFactory(Services.SERVICENAME_PERSISTENCE);
|
| JbpmContext jbpmContext;
|
| ProcessInstance processInstance = null;
| ContextInstance contextInstance = null;
| TaskMgmtInstance taskMgmtInstance = null;
| long processInstanceId = -1;
|
| public void setUp() {
| dbPersistenceServiceFactory.createSchema();
| deployProcess();
| jbpmContext = jbpmConfiguration.createJbpmContext();
| }
|
| public void tearDown() {
| jbpmContext.close();
| // dbPersistenceServiceFactory.dropSchema();
| jbpmContext = null;
| }
|
| public void newTransaction() {
| jbpmContext.close();
| jbpmContext = jbpmConfiguration.createJbpmContext();
| }
|
| public void deployProcess() {
| JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
| try {
| ProcessDefinition processDefinition =
| ProcessDefinition.parseXmlResource("processdefinition.xml");
| jbpmContext.deployProcessDefinition(processDefinition);
| } finally {
| jbpmContext.close();
| }
| }
|
| public void loadIdentities() {
| JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
| try {
| Entity[] entities = IdentityXmlParser.parseEntitiesResource("hsqldb/identity.db.xml");
| IdentitySession identitySession = new IdentitySession(jbpmContext.getSession());
| for (int i=0; i<entities.length; i++) {
| identitySession.saveEntity(entities);
| }
| } finally {
| jbpmContext.close();
| }
| }
|
| public TaskInstance createNewProcessInstance() {
| processInstance = jbpmContext.newProcessInstanceForUpdate("websale");
| processInstanceId = processInstance.getId();
| contextInstance = processInstance.getContextInstance();
| taskMgmtInstance = processInstance.getTaskMgmtInstance();
| return processInstance.getTaskMgmtInstance().createStartTaskInstance();
| }
|
| public void reloadProcessInstance() {
| processInstance = jbpmContext.loadProcessInstanceForUpdate(processInstanceId);
| contextInstance = processInstance.getContextInstance();
| taskMgmtInstance = processInstance.getTaskMgmtInstance();
| }
|
| public void testWebSaleOrderTaskParameters() {
| TaskInstance taskInstance = createNewProcessInstance();
| assertEquals("Create new web sale order", taskInstance.getName());
| assertEquals(0, taskInstance.getVariables().size());
| }
|
| public void testPerformWebSaleOrderTask() {
| jbpmContext.setActorId("user");
| // create a task to start the websale process
| TaskInstance taskInstance = createNewProcessInstance();
|
| Map taskVariables = new HashMap();
| taskVariables.put("item", "cookies");
| taskVariables.put("quantity", "lots of them");
| taskVariables.put("address", "46 Main St.");
|
| taskInstance.addVariables(taskVariables);
| taskInstance.end();
|
| assertEquals("cookies", contextInstance.getVariable("item"));
| assertEquals("lots of them", contextInstance.getVariable("quantity"));
| assertEquals("46 Main St.", contextInstance.getVariable("address"));
| assertEquals("user", taskMgmtInstance.getSwimlaneInstance("buyer").getActorId());
| }
|
| public void testEvaluateAssignment() {
| jbpmContext.setActorId("user");
| // create a task to start the websale process
| TaskInstance taskInstance = createNewProcessInstance();
| taskInstance.setVariable("item", "cookies");
| taskInstance.end();
| jbpmContext.save(processInstance);
| processInstanceId = processInstance.getId();
|
| newTransaction();
|
| List sampleManagersTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
| assertEquals(1, sampleManagersTasks.size());
|
| TaskInstance evaluateTaskInstance = (TaskInstance) sampleManagersTasks.get(0);
| assertEquals("manager", evaluateTaskInstance.getActorId());
| assertEquals("Evaluate web order", evaluateTaskInstance.getName());
| assertNotNull(evaluateTaskInstance.getToken());
| assertNotNull(evaluateTaskInstance.getCreate());
| assertNull(evaluateTaskInstance.getStart());
| assertNull(evaluateTaskInstance.getEnd());
| }
|
| public void testEvaluateOk() {
| TaskInstance taskInstance = createNewProcessInstance();
| taskInstance.end();
| jbpmContext.save(processInstance);
|
| newTransaction();
|
| TaskInstance evaluateTaskInstance = (TaskInstance) jbpmContext.getTaskMgmtSession().findTaskInstances("manager").get(0);
| evaluateTaskInstance.end("OK");
| jbpmContext.save(evaluateTaskInstance);
|
| newTransaction();
|
| List sampleShippersTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("shipper");
| assertEquals(1, sampleShippersTasks.size());
|
| TaskInstance waitForMoneyTaskInstance = (TaskInstance) sampleShippersTasks.get(0);
| assertEquals("shipper", waitForMoneyTaskInstance.getActorId());
| assertEquals("Wait for money", waitForMoneyTaskInstance.getName());
| assertNotNull(waitForMoneyTaskInstance.getToken());
| assertNotNull(waitForMoneyTaskInstance.getCreate());
| assertNull(waitForMoneyTaskInstance.getStart());
| assertNull(waitForMoneyTaskInstance.getEnd());
| }
|
| public void testUnwritableVariableException() {
| testEvaluateAssignment();
| newTransaction();
| List sampleManagersTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
| TaskInstance evaluateTaskInstance = (TaskInstance) sampleManagersTasks.get(0);
| evaluateTaskInstance.end();
|
| newTransaction();
|
| processInstance = jbpmContext.getGraphSession().loadProcessInstance(processInstanceId);
| contextInstance = processInstance.getContextInstance();
| // so the cookies should still be in the item process variable.
| assertEquals("cookies", contextInstance.getVariable("item"));
| }
|
| public void testEvaluateNok() {
| testEvaluateAssignment();
| newTransaction();
|
| List sampleManagersTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("manager");
| TaskInstance evaluateTaskInstance = (TaskInstance) sampleManagersTasks.get(0);
| evaluateTaskInstance.setVariable("comment", "wtf");
| evaluateTaskInstance.end("More info needed");
| jbpmContext.save(evaluateTaskInstance);
|
| newTransaction();
|
| List sampleUserTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("user");
| assertEquals(1, sampleUserTasks.size());
| TaskInstance fixWebOrderDataTaskInstance = (TaskInstance) sampleUserTasks.get(0);
| assertEquals("user", fixWebOrderDataTaskInstance.getActorId());
| assertEquals("wtf", fixWebOrderDataTaskInstance.getVariable("comment"));
| }
|
| public void testMoreInfoNeeded() {
| jbpmContext.setActorId("user");
|
| // create a task to start the websale process
| TaskInstance taskInstance = createNewProcessInstance();
| taskInstance.end();
| jbpmContext.save(processInstance);
|
| newTransaction();
|
| TaskInstance evaluateTaskInstance = (TaskInstance) jbpmContext.getTaskMgmtSession().findTaskInstances("manager").get(0);
| evaluateTaskInstance.end("More info needed");
| jbpmContext.save(evaluateTaskInstance);
|
| newTransaction();
|
| List sampleUserTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("user");
| assertEquals(1, sampleUserTasks.size());
|
| TaskInstance fixWebOrderDataTaskInstance = (TaskInstance) sampleUserTasks.get(0);
| assertEquals("user", fixWebOrderDataTaskInstance.getActorId());
| assertEquals("Fix web order data", fixWebOrderDataTaskInstance.getName());
| assertNotNull(fixWebOrderDataTaskInstance.getToken());
| assertNotNull(fixWebOrderDataTaskInstance.getCreate());
| assertNull(fixWebOrderDataTaskInstance.getStart());
| assertNull(fixWebOrderDataTaskInstance.getEnd());
| }
| }
|
i didn't change anything in the processdefinition or any of the classes that came with this example accept this test case...
i'll make a test case for my process definition....and get back to u...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110414#4110414
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110414
18 years, 4 months