Author : Dumitru Ciubenco ##############################
Features:
- OrientDB 1.3.0 upgrade
Features:
- POJO save
- POJO retrieve
- Bug fixing
- Refactoring
- OrientDB 1.2.0 upgrade
Features:
- OGraphDatabasePool support
- OGraphDatabase support
- Transaction support
Tested only on JBoss 7.1.1
- Build the source code using maven
- Deploy the orientdb-jca-connector-1.2.0.rar to your jboss
- Add resource addapter definition in your standalone.xml
<resource-adapter>
<archive>
orientdb-jca-connector-1.2.0.rar
</archive>
<transaction-support>XATransaction</transaction-support>
<connection-definitions>
<connection-definition class-name="eu.devexpert.orient.jca.OrientDBManagedConnectionFactoryImpl" jndi-name="java:/jca/stylysh-orientdb" enabled="true" use-java-context="true" pool-name="stylysh-orient-db-jca-pool">
<config-property name="username">
admin
</config-property>
<config-property name="configFileLevel">
info
</config-property>
<config-property name="configProfiler">
false
</config-property>
<config-property name="connectionUrl">
local:${jboss.server.config.dir}/orient-db/stylysh
</config-property>
<config-property name="configDump">
true
</config-property>
<config-property name="configConsoleLevel">
info
</config-property>
<config-property name="configPoolMaxSize">
20
</config-property>
<config-property name="xa">
true
</config-property>
<config-property name="configPoolMinSize">
3
</config-property>
<config-property name="password">
admin
</config-property>
<config-property name="configEncoding">
utf8
</config-property>
<xa-pool>
<min-pool-size>3</min-pool-size>
<max-pool-size>15</max-pool-size>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
</xa-pool>
<security>
<application/>
</security>
</connection-definition>
</connection-definitions>
</resource-adapter>
- Add the deployment dependency to your(pom.xml if you are using maven) or to the MANIFEST.MF: deployment.orientdb-jca-connector-1.3.0-SNAPSHOT.rar
- Add the dependency to your project:
<dependency>
<groupId>eu.devexpert</groupId>
<artifactId>orientdb-jca-api</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.jboss.ironjacamar</groupId>
<artifactId>ironjacamar-spec-api</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>
- Use it in your application:
@Named("graphService")
@Stateless
public class GraphService implements Serializable {
@Resource(mappedName = "java:/jca/orientDb")
private OrientDBConnectionFactory odb;
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void initMyClasses() {
try {
odb.graph().createVertexType("NodeClass1");
odb.graph().createVertexType("NodeClass2");
} catch (ResourceException e) {
e.printStackTrace();
}
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void createNode(Map fields) {
try {
ODocument node = odb.graph().createVertex("NodeClass1");
node.fields(fields);
node.save();
} catch (ResourceException e) {
e.printStackTrace();
}
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void createNewNode(MyBean object) {
try {
odb.graph().saveNode(object);
} catch (ResourceException e) {
e.printStackTrace();
}
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void createOrUpdateMyNode(MyBean object) {
try {
odb.graph().saveOrUpdateNode(object,"beanField1","beanField2"...);
} catch (ResourceException e) {
e.printStackTrace();
}
}
}