Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Persist EObject from BPEL20.XSD
Persist EObject from BPEL20.XSD [message #609578] Wed, 29 August 2007 08:10
Daniel Gerlach is currently offline Daniel GerlachFriend
Messages: 36
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------040600040208030303090305
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

i want to persist an Object of the following XML-Schema:
http://docs.oasis-open.org/wsbpel/2.0/OS/process/executable/ ws-bpel_executable.xsd

So, i generated the Ecore-model. Then i loaded an BPEL-XML(the xml file
is added) into EMF and i want to persist this file in my database with
Teneo.

I use the newest Teneo 0.8 build, eclipse3.3, Java 1.6u2 and hibernate
3.2.4SP1.

The generation of the hibernate-mapping and the database schema was
successful.

But if i want to persist an Object of the loaded BPEL-file, especially
the TProcess-object because it comes right after the DocumentRoot. But i
always get an hibernate-error. I have tried to change the mapping-file
manually but it didn't work.


My Code:

package org.teneo.test;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.teneo.PersistenceOptions;
import org.eclipse.emf.teneo.hibernate.HbDataStore;
import org.eclipse.emf.teneo.hibernate.HbHelper;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Environment;
import org.open.oasis.docs.wsbpel._2._0.process.executable.Document Root;
import
org.open.oasis.docs.wsbpel._2._0.process.executable.Executab lePackage;
import org.open.oasis.docs.wsbpel._2._0.process.executable.TFlow;
import org.open.oasis.docs.wsbpel._2._0.process.executable.TProcess ;
import
org.open.oasis.docs.wsbpel._2._0.process.executable.util.Exe cutableResourceFactoryImpl;
import org.w3.xml._1998.namespace.NamespacePackage;

public class Test2 {
public static void main(String[] args) {

// initDB();
// createDatabase();
persistResource();
// persistRootFromXML();
// loadBPELFileFromDB();
}

public static void createDatabase() {
HbDataStore dataStore = initDB();
dataStore.initialize();
}

public static HbDataStore initDB() {
final String dataStoreName = "bpel20";
final HbDataStore dataStore = (HbDataStore) HbHelper.INSTANCE
.createRegisterDataStore(dataStoreName);
Properties hibernateProperties = new Properties();
hibernateProperties.setProperty(Environment.DRIVER,
"org.postgresql.Driver");
hibernateProperties.setProperty(Environment.USER, "postgres");
hibernateProperties.setProperty(Environment.URL,
"jdbc:postgresql://127.0.0.1:5432/bpel20");
hibernateProperties.setProperty(Environment.PASS, "XXXXX");
hibernateProperties.setProperty(Environment.DIALECT,
"org.hibernate.dialect.PostgreSQLDialect");

dataStore.setHibernateProperties(hibernateProperties);
Properties persistenceOptions = new Properties();
persistenceOptions.setProperty(PersistenceOptions.INHERITANC E_MAPPING,
"JOINED");
persistenceOptions.setProperty(
PersistenceOptions.FETCH_CONTAINMENT_EAGERLY, "true");
persistenceOptions.setProperty(
PersistenceOptions.SET_CASCADE_ALL_ON_CONTAINMENT, "true");
persistenceOptions.setProperty(PersistenceOptions.USE_MAPPIN G_FILE,
"true");
dataStore.setPersistenceProperties(persistenceOptions);

dataStore.setEPackages(new EPackage[] { ExecutablePackage.eINSTANCE,
NamespacePackage.eINSTANCE });
return dataStore;
}

public static void persistResource() {
TProcess process = loadProcessFromFile();
// init Session
HbDataStore dataStore = initDB();
final SessionFactory sessionFactory = dataStore.getSessionFactory();
final Session session = sessionFactory.openSession();
// start Transaction
session.beginTransaction();
session.save(process);

session.getTransaction().commit();
session.close();

}

public static TProcess loadProcessFromFile() {
TProcess process = null;
// Create a resource set to hold the resources.
//
ResourceSet resourceSet = new ResourceSetImpl();

// Register the appropriate resource factory to handle all file
// extensions.
//
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
new ExecutableResourceFactoryImpl());

// Register the package to ensure it is available during loading.
//
resourceSet.getPackageRegistry().put(ExecutablePackage.eNS_U RI,
ExecutablePackage.eINSTANCE);
// Demand load resource for this file.
//
File file = new File(
"c:\\eclipse\\workspace\\BPEL20\\bpel20Example.bpel");
URI uri = URI.createFileURI(file.getAbsolutePath());
Resource resource = resourceSet.getResource(uri, true);
System.out.println("Loaded " + uri);

// Validate the contents of the loaded resource.
//
for (EObject eObject : resource.getContents()) {

System.out.println("Klasse des EObjects: " + eObject.getClass());

DocumentRoot docuRoot = (DocumentRoot) eObject;
for (TreeIterator<EObject> it = docuRoot.eAllContents(); it
.hasNext();) {

EObject eObject2 = it.next();
// System.out.println("Alle Klassen des rootObjekts: "
// + eObject2.getClass());
if (eObject2 instanceof TProcess) {
process = (TProcess) eObject2;
}
}
}
return process;
}
}


The following error occurs:

15548 [main] DEBUG org.hibernate.type.LongType - binding '91' to
parameter: 3
15548 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - Executing batch
size: 2
15579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close
PreparedStatement (open PreparedStatements: 1, globally: 1)
15579 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
15579 [main] ERROR org.hibernate.util.JDBCExceptionReporter -
Batch-Eintrag 0 update "texpression_mixed" set
"texpression_mixed_e_id"=87, "texpression_mixed_idx"=0 where id=88 wurde
abgebrochen. Rufen Sie 'getNextException' auf, um die Ursache zu erfahren.
15579 [main] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR:
insert or update on table "texpression_mixed" violates foreign key
constraint "fk987fc8082ce0ea45"
Detail: Key (texpression_mixed_e_id)=(87) is not present in table
"texpression_any".
15579 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener
- Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute
JDBC batch update
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateCo nverter.java:71)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExce ptionHelper.java:43)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatc her.java:253)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:92)
at
org.hibernate.jdbc.AbstractBatcher.prepareStatement(Abstract Batcher.java:87)
at
org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(Abs tractBatcher.java:222)
at
org.hibernate.persister.collection.AbstractCollectionPersist er.recreate(AbstractCollectionPersister.java:1119)
at
org.hibernate.action.CollectionRecreateAction.execute(Collec tionRecreateAction.java:26)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:25 0)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue. java:145)
at
org.hibernate.event.def.AbstractFlushingEventListener.perfor mExecutions(AbstractFlushingEventListener.java:298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java :338)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransac tion.java:106)
at org.teneo.test.MainTest.persistResource(MainTest.java:171)
at org.teneo.test.MainTest.main(MainTest.java:38)
Caused by: java.sql.BatchUpdateException: Batch-Eintrag 0 update
"texpression_mixed" set "texpression_mixed_e_id"=87,
"texpression_mixed_idx"=0 where id=88 wurde abgebrochen. Rufen Sie
'getNextException' auf, um die Ursache zu erfahren.
at
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandl er.handleError(AbstractJdbc2Statement.java:2534)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(Quer yExecutorImpl.java:1317)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecut orImpl.java:350)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(Abs tractJdbc2Statement.java:2596)
at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBa tcher.java:48)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatc her.java:246)
... 15 more
15579 [main] DEBUG org.hibernate.jdbc.ConnectionManager - registering
flush end

With kind regards

Daniel Gerlach

--------------040600040208030303090305
Content-Type: text/xml;
name="bpel20Example.bpel"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="bpel20Example.bpel"

<?xml version="1.0" encoding="UTF-8"?>

<bpel:process

xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"

xmlns:lns="http://loans.org/wsdl/loanapproval"

xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="loanapproval"

suppressJoinFailure="yes" targetNamespace="http://loanapproval">

<bpel:import importType="http://schemas.xmlsoap.org/wsdl/"

location="loanapproval.wsdl"

namespace="http://loans.org/wsdl/loanapproval" />

<bpel:partnerLinks>

<bpel:partnerLink myRole="loanService" name="customer"

partnerLinkType="lns:loanServicePartnerLinkType" />

<bpel:partnerLink name="assessor"

partnerLinkType="lns:riskAssessmentPartnerLinkType"

partnerRole="assessor" />

<bpel:partnerLink name="approver"

partnerLinkType="lns:loanApprovalPartnerLinkType"

partnerRole="approver" />

</bpel:partnerLinks>

<bpel:variables>

<bpel:variable messageType="lns:creditInformationMessage"

name="request" />

<bpel:variable messageType="lns:approvalMessage"

name="approval" />

<bpel:variable messageType="lns:riskAssessmentMesssage"

name="risk" />

</bpel:variables>

<bpel:flow>

<bpel:links>

<bpel:link name="receive-to-assess" />

<bpel:link name="receive-to-approve" />

<bpel:link name="assess-to-approve" />

<bpel:link name="assess-to-assign" />

<bpel:link name="approve-to-reply" />

<bpel:link name="assign-to-reply" />

</bpel:links>

<bpel:receive createInstance="yes"

name="ReceiveCustomerRequestforLoanAmt" operation="request"

partnerLink="customer" portType="lns:loanServicePT"

variable="request">

<bpel:sources>

<bpel:source linkName="receive-to-assess">

<bpel:transitionCondition

expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0 ">

$request.amount &lt;10000

</bpel:transitionCondition>

</bpel:source>

<bpel:source linkName="receive-to-approve">

<bpel:transitionCondition

expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0 ">

$request.amount &gt;= 10000

</bpel:transitionCondition>

</bpel:source>

</bpel:sources>

</bpel:receive>

<bpel:reply name="AcceptMessageToCustomer" operation="request"

partnerLink="customer" portType="lns:loanServicePT"

variable="approval">

<bpel:targets>

<bpel:target linkName="assign-to-reply" />

<bpel:target linkName="approve-to-reply" />

</bpel:targets>

</bpel:reply>

<bpel:invoke inputVariable="request" name="InvokeLoanAssessor"

operation="check" outputVariable="risk" partnerLink="assessor"

portType="lns:riskAssessmentPT">

<bpel:targets>

<bpel:target linkName="receive-to-assess" />

</bpel:targets>

<bpel:sources>

<bpel:source linkName="assess-to-approve">

<bpel:transitionCondition

expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0 ">

$risk.level != 'low'

</bpel:transitionCondition>

</bpel:source>

<bpel:source linkName="assess-to-assign">

<bpel:transitionCondition

expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0 ">

$risk.level = 'low'

</bpel:transitionCondition>

</bpel:source>

</bpel:sources>

</bpel:invoke>

<bpel:invoke inputVariable="request" name="InvokeLoanApprover"

operation="approve" outputVariable="approval" partnerLink="approver"

portType="lns:loanApprovalPT">

<bpel:targets>

<bpel:target linkName="receive-to-approve" />

<bpel:target linkName="assess-to-approve" />

</bpel:targets>

<bpel:sources>

<bpel:source linkName="approve-to-reply" />

</bpel:sources>

</bpel:invoke>

<bpel:assign name="AssignYestoAccept">

<bpel:targets>

<bpel:target linkName="assess-to-assign" />

</bpel:targets>

<bpel:sources>

<bpel:source linkName="assign-to-reply" />

</bpel:sources>

<bpel:copy>

<bpel:from>

<bpel:literal>yes</bpel:literal>

</bpel:from>

<bpel:to part="accept" variable="approval" />

</bpel:copy>

</bpel:assign>

</bpel:flow>

</bpel:process>


--------------040600040208030303090305--
Previous Topic:[CDO/NET4J][0.8.0] Failover mechanism
Next Topic:[CDO] JPA
Goto Forum:
  


Current Time: Thu Aug 11 16:01:49 GMT 2022

Powered by FUDForum. Page generated in 0.01851 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top