JBPM 6.4で新しいリポジトリと新しいプロジェクトを作成しました。プロジェクトの中に私はpersistence.xml
を作成しました:JBPM 6.4プロジェクトの永続ユニット
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd">
<persistence-unit name="demox:com.prueba:1.0" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/jbpmDS</jta-data-source>
<class>demox.com.prueba.Estudiante</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.id.new_generator_mappings" value="false"/>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform"/>
</properties>
</persistence-unit>
</persistence>
また、私はpersistibleオブジェクト(@Entity
で飾らPOJO)で定義されました。
ここでは、1つのスクリプトタスクで簡単な処理を行っています。
しかし、私は私のDBにプロセスを展開したときStudent
テーブルが作成されます...
package demox.com.prueba;
/**
* This class was automatically generated by the data modeler tool.
*/
@javax.persistence.Entity
public class Estudiante implements java.io.Serializable
{
static final long serialVersionUID = 1L;
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO, generator = "ESTUDIANTE_ID_GENERATOR")
@javax.persistence.Id
@javax.persistence.SequenceGenerator(name = "ESTUDIANTE_ID_GENERATOR", sequenceName = "ESTUDIANTE_ID_SEQ")
private java.lang.Long id;
@org.kie.api.definition.type.Label(value = "name")
private java.lang.String name;
public Estudiante()
{
}
public java.lang.Long getId()
{
return this.id;
}
public void setId(java.lang.Long id)
{
this.id = id;
}
public java.lang.String getName()
{
return this.name;
}
public void setName(java.lang.String name)
{
this.name = name;
}
public Estudiante(java.lang.Long id, java.lang.String name)
{
this.id = id;
this.name = name;
}
}
がそこで質問がされています。このscriptTask
内部で取得する方法このEntityManger
への参照は、このPOJOを永続化します?
は、私が試した:
demox.com.prueba.Estudiante est=new demox.com.prueba.Estudiante();
String pu="demox:com.prueba:1.0";
//javax.persistence.EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory(pu);
javax.persistence.EntityManagerFactory emf = (javax.persistence.EntityManagerFactory) kcontext.getKnowledgeRuntime().getEnvironment()
.get(org.kie.api.runtime.EnvironmentName.ENTITY_MANAGER_FACTORY); # tried also EnvironmentName.CMD_SCOPED_ENTITY_MANAGER
System.out.println("Entity manager " + emf);
emf.persist(est);
しかし、このコードを使用したときのEntityManagerは不明JBPM永続性ユニットではない、私のPOJOクラスが含まれていない私の永続ユニット(デモ)へのインスタンスへの参照(ありますエンティティ)。
スクリプトタスクでこのパーシスタンスユニットにどのようにアクセスできますか?