[Schmitzm-commits] r766 - in trunk/src/skrueger/orm: . accessor
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Mar 15 22:40:32 CET 2010
Author: alfonx
Date: 2010-03-15 22:40:27 +0100 (Mon, 15 Mar 2010)
New Revision: 766
Removed:
trunk/src/skrueger/orm/AbstractEntity.java
trunk/src/skrueger/orm/PersistentEntity.java
trunk/src/skrueger/orm/accessor/AbstractEntityAccessor.java
trunk/src/skrueger/orm/accessor/EntityAccessorException.java
Log:
Deleted: trunk/src/skrueger/orm/AbstractEntity.java
===================================================================
--- trunk/src/skrueger/orm/AbstractEntity.java 2010-03-15 16:42:35 UTC (rev 765)
+++ trunk/src/skrueger/orm/AbstractEntity.java 2010-03-15 21:40:27 UTC (rev 766)
@@ -1,36 +0,0 @@
-package skrueger.orm;
-
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-
-/**
- *
- * @author Dr. Spock (spock at dev.java.net)
- */
- at MappedSuperclass
-public abstract class AbstractEntity implements PersistentEntity<Long> {
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- public Long getId() {
- return this.id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- @Override
- public abstract boolean equals(Object object);
-
- @Override
- public abstract int hashCode();
-
- @Override
- public abstract String toString();
-
-}
Deleted: trunk/src/skrueger/orm/PersistentEntity.java
===================================================================
--- trunk/src/skrueger/orm/PersistentEntity.java 2010-03-15 16:42:35 UTC (rev 765)
+++ trunk/src/skrueger/orm/PersistentEntity.java 2010-03-15 21:40:27 UTC (rev 766)
@@ -1,14 +0,0 @@
-package skrueger.orm;
-
-
-import java.io.Serializable;
-
-/**
- *
- * @author Dr. Spock (spock at dev.java.net)
- */
-public interface PersistentEntity<PK extends Serializable> extends Serializable {
-
- PK getId();
-
-}
Deleted: trunk/src/skrueger/orm/accessor/AbstractEntityAccessor.java
===================================================================
--- trunk/src/skrueger/orm/accessor/AbstractEntityAccessor.java 2010-03-15 16:42:35 UTC (rev 765)
+++ trunk/src/skrueger/orm/accessor/AbstractEntityAccessor.java 2010-03-15 21:40:27 UTC (rev 766)
@@ -1,96 +0,0 @@
-package skrueger.orm.accessor;
-
-
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.annotation.Resource;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnit;
-import javax.transaction.Status;
-import javax.transaction.UserTransaction;
-
-/**
- *
- * @author Dr. Spock (spock at dev.java.net)
- */
-public abstract class AbstractEntityAccessor {
-
- @PersistenceUnit
- private EntityManagerFactory emf;
- @Resource
- private UserTransaction userTransaction;
-
- private AtomicInteger count;
-
- public AbstractEntityAccessor() {
- count = new AtomicInteger(0);
- }
-
- protected final <T> T doInTransaction(PersistenceAction<T> action) throws EntityAccessorException {
- EntityManager em = emf.createEntityManager();
- try {
- int status = 0;
- if (Status.STATUS_ACTIVE != (status = userTransaction.getStatus())){
- count.incrementAndGet();
- userTransaction.begin();
- }
- T result = action.execute(em);
- if (Status.STATUS_ACTIVE == (status = userTransaction.getStatus())) {
- if (0 == count.decrementAndGet()) {
- userTransaction.commit();
- }
- }
- return result;
- } catch (Exception e) {
- try {
- userTransaction.rollback();
- } catch (Exception ex) {
- Logger.getLogger(AbstractEntityAccessor.class.getName()).log(Level.SEVERE, null, ex);
- }
- throw new EntityAccessorException(e);
- } finally {
- em.close();
- }
-
- }
-
- protected final void doInTransaction(PersistenceActionWithoutResult action) throws EntityAccessorException {
- EntityManager em = emf.createEntityManager();
- try {
- int status = 0;
- if (Status.STATUS_ACTIVE != (status = userTransaction.getStatus())){
- count.incrementAndGet();
- userTransaction.begin();
- }
- action.execute(em);
- if (Status.STATUS_ACTIVE == (status = userTransaction.getStatus())) {
- if (0 == count.decrementAndGet()) {
- userTransaction.commit();
- }
- }
- } catch (Exception e) {
- try {
- userTransaction.rollback();
- } catch (Exception ex) {
- Logger.getLogger(AbstractEntityAccessor.class.getName()).log(Level.SEVERE, null, ex);
- }
- throw new EntityAccessorException(e);
- } finally {
- em.close();
- }
- }
-
- protected static interface PersistenceAction<T> {
-
- T execute(EntityManager em);
- }
-
- protected static interface PersistenceActionWithoutResult {
-
- void execute(EntityManager em);
- }
-
-}
Deleted: trunk/src/skrueger/orm/accessor/EntityAccessorException.java
===================================================================
--- trunk/src/skrueger/orm/accessor/EntityAccessorException.java 2010-03-15 16:42:35 UTC (rev 765)
+++ trunk/src/skrueger/orm/accessor/EntityAccessorException.java 2010-03-15 21:40:27 UTC (rev 766)
@@ -1,14 +0,0 @@
-package skrueger.orm.accessor;
-
-public class EntityAccessorException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public EntityAccessorException(Throwable cause) {
- super(cause);
- }
-
- public EntityAccessorException(String message, Throwable cause) {
- super(message, cause);
- }
-}
More information about the Schmitzm-commits
mailing list