Skip to content

Commit

Permalink
handle transaction management with annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Kowalewski committed Aug 16, 2013
1 parent 2cb5d9f commit 43fb29f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/main/java/com/comsysto/neo4j/showcase/main/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.comsysto.neo4j.showcase.main;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.transaction.jta.JtaTransactionManager;

import javax.transaction.*;

Expand All @@ -16,13 +15,8 @@ public static void main(String[] args) throws SystemException, NotSupportedExcep

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(CLASSPATH_LOCATION);

JtaTransactionManager tx = (JtaTransactionManager) context.getBean("neo4jTransactionManager");
Neo4jPersister neo4jPersister = (Neo4jPersister) context.getBean("neo4jPersister");

tx.getTransactionManager().begin();

neo4jPersister.createTestData();

tx.getTransactionManager().commit();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.comsysto.neo4j.showcase.main;

import com.comsysto.neo4j.showcase.model.Product;
import com.comsysto.neo4j.showcase.repository.ProductRepository;
import com.comsysto.neo4j.showcase.model.User;
import com.comsysto.neo4j.showcase.repository.ProductRepository;
import com.comsysto.neo4j.showcase.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
* @author: rkowalewski
*/
@Component
@Transactional(propagation = Propagation.REQUIRED)
@Transactional
public class Neo4jPersister {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<context:spring-configured/>
<context:annotation-config/>

<tx:annotation-driven/>

<neo4j:config storeDirectory="target/data/db_main"/>

<neo4j:repositories base-package="com.comsysto.neo4j.showcase.repository"/>
Expand Down

0 comments on commit 43fb29f

Please sign in to comment.