Skip to content

kirpi4ik/orientdb-jca

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Author : Dumitru Ciubenco ##############################

OrientDB JCA connector

############################## Version 1.3.0

Features:

  • OrientDB 1.3.0 upgrade

Version 1.2.0

Features:

  • POJO save
  • POJO retrieve
  • Bug fixing
  • Refactoring
  • OrientDB 1.2.0 upgrade

Version 1.1.0

Features:

  • OGraphDatabasePool support
  • OGraphDatabase support
  • Transaction support

Tested only on JBoss 7.1.1

Usage

  1. Build the source code using maven
  2. Deploy the orientdb-jca-connector-1.2.0.rar to your jboss
  3. 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>

  1. 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
  2. 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>		

  1. 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();
		}
	}	
}

About

OrientDB JCA connector

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages