[jboss-user] [JBoss jBPM] - [newbie] problem with hibernate mapping while trying to save

colablade do-not-reply at jboss.com
Sun Jul 1 08:19:52 EDT 2007


Hello,
  Working on JBoss IDE 2.0.0 BETA2 with jBPM 3.1.3, I was trying to store some data to my own table, instead of jbpm_variableinstance. The JUnit test ran perfectly, but an "org.hibernate.MappingException: Unknown entity" exception occurred while running on Tomcat 5.5 after deployment.
  Here goes the details:
1. the table creation script:

  | create table student (
  |  id varchar(100) not null default '',
  |  name varchar(20) default '',
  |  age int(11) default 0,
  |  primary key (id)
  | );
  | 
2. the corresponding Student classes (generated by hibernate synchronizer):

  | package dgbdatamodel;
  | ...
  | 	// primary key
  | 	private java.lang.String id;
  | 
  | 	// fields
  | 	private java.lang.String name;
  | 	private java.lang.Integer age;
  | ...
  | 	// getters and setters
  | 
3. the mapping file (also generated by hibernate synchronizer):

  | <?xml version="1.0"?>
  | <!DOCTYPE hibernate-mapping PUBLIC
  | 	"-//Hibernate/Hibernate Mapping DTD//EN"
  | 	"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
  | 
  | <hibernate-mapping package="dgbdatamodel">
  | 	<class
  | 		name="Student"
  | 		table="student"
  | 	>
  | 		<meta attribute="sync-DAO">false</meta>
  | 		<id
  | 			name="Id"
  | 			type="string"
  | 			column="id"
  | 		>
  | 			<generator class="uuid.hex"/>
  | 		</id>
  | 
  | 		<property
  | 			name="Name"
  | 			column="name"
  | 			type="string"
  | 			not-null="false"
  | 			length="20"
  | 		/>
  | 		<property
  | 			name="Age"
  | 			column="age"
  | 			type="integer"
  | 			not-null="false"
  | 			length="11"
  | 		/>
  | 	</class>	
  | </hibernate-mapping>
  | 
  I used the auto-generated simple process, and added the following code to the MessageActionHandler.execute function:

  | 		stu = new Student();
  | 		stu.setName("the hell");
  | 		JbpmConfiguration cfg = JbpmConfiguration.getInstance(); 
  | 		JbpmContext jbpmContext = cfg.createJbpmContext();
  | 		try {
  | 		  // Invoke persistence operations here
  | 			Session s = jbpmContext.getSession();
  | 			s.save(stu);
  | 		} finally {
  | 		  jbpmContext.close();
  | 		}
  | 
the 'stu' is a member variable of MessageActionHandler.

  I first ran the sample SimpleProcessTest as JUnit test, and got 2 students named "the hell" in the table student ('cos the action was called twice in the test). Then I used JBoss IDE to deploy the process. The deployed archive includes the process, MessageActionHandler, the dgbdatamodel package, hibernate.cfg.xml as well as Student.hbm.xml. After logging in in the browser I started a new 'simple' process, after input 'color' and 'size' and clicked "Save and Close Task" (and the action handler is called), i got

  | javax.servlet.ServletException: Error calling action method of component with id taskform:transitionButton
  | ...
  | root cause
  | javax.faces.FacesException: Error calling action method of component with id taskform:transitionButton
  | ...
  | 
  the log says sth like:

  | ...
  | 19:39:53,765 DEBUG [Services] closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService at ec1e6f
  | 19:39:53,765 DEBUG [DbPersistenceService] committing hibernate transaction
  | 19:39:53,781 DEBUG [DbPersistenceService] closing hibernate session
  | 19:39:53,781 ERROR [GraphElement] action threw exception: Unknown entity: dgbdatamodel.Student
  | org.hibernate.MappingException: Unknown entity: dgbdatamodel.Student
  | 	at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:610)
  | 	at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1246)
  | ...
  | 
  I guess the deployed version didn't include the mapping declared in "Student.hbm.xml" (since if I don't call "s.save(stu)" in the action handler, no exception was thrown).
  I searched the forum for the answer, but in vain, the closest one I got is:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=89365 
  However, I just started learning jBPM and got stuck in here for quite a few days. Anyone's kind enough to give me some clues? Or what is the right way to do the job? Thanks a million!


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059442#4059442

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4059442



More information about the jboss-user mailing list