The Infinity Process Platform installation contains a small example on how to use this data type. Click the following link to download this example in a ZIP file:
Unpack the ZIP file to an example location. We refer to this folder as <hibernate-example>. The folder provides a process model as well as source files needed for the project. The example process model, which resides in folder <hibernate-example>/hibernate/dat, covers the following use cases:
You can import this process model into an Eclipse project. The classes used in the examples are located in the hibernate/src folder.
To execute the example it is necessary to set up a Infinity Process Platform Audit Trail. The examples are based on a Derby database.
Per default the standard Infinity audit trail is used. In case you
like to use another audit trail or database, you need to adjust the
ipp-hibernate-spring-context.xml file located in the
WEB-INF/config/ipp/spring folder of your Web application.
hibernateDataSource Spring bean accordingly and,
if you do not use a Derby database, the
Prepare the working environment for this example:
If you like to use the configuration without Spring, use the
hibernate.cfg.xml file provided in the example. In that case
you have to adjust one of the following context files depending on the environment
your work in:
ipp-hibernate-spring-context.xmlfile residing in the
ipp-portal/WEB-INF/config/ipp/springfolder of your RAD environment
carnot-spring-hibernate-context.xmlfile residing in your archetype
Adjust the context file to the following content:
<?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (c) 2011, 2015 SunGard CSA LLC and others. --> <!-- - Application context for a Infinity Process Engine client. --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd"> <bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="hibernateDataSource" /> </property> <property name="jtaTransactionManager"> <bean factory-bean="carnotTxManager" factory-method="getTransactionManager"/> </property> <property name="configLocation"> <value>classpath:com/sungard/hibernate/hibernate.cfg.xml</value> </property> </bean> <!-- Use xaAuditTrailConnectionFactory if you want to use the same datasource as the Engine. Otherwise configure the hibernateJNDIDataSource if you want to use a different datasource and set the name attribute to hibernateJNDIDataSource --> <alias name="xaAuditTrailConnectionFactory" alias="hibernateDataSource" /> <jee:jndi-lookup id="hibernateJNDIDataSource" lazy-init="true" jndi-name="jdbc/AuditTrail.DataSource" resource-ref="true" /> </beans>
If working in RAD, adjust the
hibernate.cfg.xml as follows:
<?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.DerbyDialect</property> <property name="hibernate.connection.autocommit">false</property> <!-- this will show us all sql statements --> <property name="hibernate.show_sql">true</property> <!-- this will create the database tables for us --> <property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.cache.use_second_level_cache">false</property> <mapping resource="com/sungard/hibernate/employee.hbm.xml"/> </session-factory> </hibernate-configuration>
Extend the hibernateSessionFactory with the following property:
<property name="configLocation"> <value>classpath:com/sungard/hibernate/hibernate.cfg.xml</value> </property>
For our Hibernate example model we provide the following processes:
First create a process to create the Hibernate data and fill it with data.
Figure: TestEmployeeApp Application Properties
Figure: Select the Class Name
Figure: Access Point for Hibernate Data
Figure: Select Subprocess
The diagram now looks similar as displayed in the following screenshot:
Figure: Create Employee Process Diagram
Now we create a process that can be used to display our Hibernate data. The process is using a condition to only display the data in case it contains values.
HibernateData != null
OTHERWISE, so that it will be performed if no Hibernate Data is set. Use
The complete process now looks similar as in the following screenshot:
Figure: HibernateInCondition Process
Create a process definition to clear hibernate data:
Figure: Clear Employee Application Properties
Figure: Out-Data Mapping to Hibernate Data.
The completed process should look like in the following screenshot:
Figure: Delete Employee Process Diagram
At last we create a process which provides the option to update a Hibernate data:
The completed process now looks similar to the one in the following screenshot:
Figure: Update Hibernate Data Process Diagram
Now deploy your model and test it, e.g. in the Infinity Process Platform Portal.
Start process CreateEmployee and enter the first name, last name and id of the Employee Hibernate Data.
Figure: Enter Hibernate Data
After completing the activity, the EmployeeInCondition is activated and displays the resulting Hibernate data with values.
Figure: Display Hibernate Data
Start process DeleteEmployee. First the subprocess CreateEmployee is activated, where you enter values for the Hibernate data and see this data displayed as described in section Creating Hibernate Data.
Now the application Delete Employee is activated returning a Null value.
The condition in subprocess EmployeeInCondition evaluates to
as the HibernateData is null. Thus the No Employee activity is activated,
which displays the NullObjInfo data notifying that no data is available.
Figure: No Employee activity
Note that the actual Hibernate object itself is not deleted, but set to null!
Start process UpdateEmployee. The subprocess activity
CreateEmployee is activated, which uses the process described in section
Creating Hibernate Data Process. As it has no incoming data to fill
the Hibernate data, it uses the Access Point
Complete() without parameters,
which creates a random value for the Employee Id.
The subsequent activity reads data for the Employee first and last name and writes them to the Hibernate data.
Figure: Enter Hibernate Data
Now subprocess EmployeeInCondition is activated to display the resulting Hibernate data. The entered last and first name are displayed with a random value for the Employee Id.
Figure: Updated Hibernate Data