diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityVerificationInterceptor.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityVerificationInterceptor.java index eacc19da9044bec9e20b4eaee0b3c3e62e584dcb..143b8c93374356da2840b6db5097cf75c3e93427 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityVerificationInterceptor.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/EntityVerificationInterceptor.java @@ -26,7 +26,6 @@ import org.hibernate.Transaction; import org.hibernate.type.Type; import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.generic.server.CommonServiceProvider; import ch.systemsx.cisd.openbis.generic.server.business.bo.dynamic_property.DynamicPropertyEvaluator; import ch.systemsx.cisd.openbis.generic.server.business.bo.dynamic_property.IDynamicPropertyEvaluator; import ch.systemsx.cisd.openbis.generic.server.business.bo.dynamic_property.calculator.EntityAdaptorFactory; @@ -57,9 +56,11 @@ public class EntityVerificationInterceptor extends EmptyInterceptor private IDAOFactory daoFactory; - public EntityVerificationInterceptor(IHibernateTransactionManagerCallback callback) + public EntityVerificationInterceptor(IHibernateTransactionManagerCallback callback, + IDAOFactory daoFactory) { this.callback = callback; + this.daoFactory = daoFactory; initializeLists(); } @@ -196,7 +197,7 @@ public class EntityVerificationInterceptor extends EmptyInterceptor { EntityValidationCalculator calculator = EntityValidationCalculator.create(script.getScript()); - IDynamicPropertyEvaluator evaluator = new DynamicPropertyEvaluator(getDAOFactory(), null); + IDynamicPropertyEvaluator evaluator = new DynamicPropertyEvaluator(daoFactory, null); IEntityAdaptor adaptor = EntityAdaptorFactory.create(entity, evaluator); calculator.setEntity(adaptor); calculator.setIsNewEntity(isNewEntity); @@ -258,13 +259,4 @@ public class EntityVerificationInterceptor extends EmptyInterceptor newDatasets = new HashSet<DataPE>(); } - private IDAOFactory getDAOFactory() - { - if (daoFactory == null) - { - daoFactory = CommonServiceProvider.getDAOFactory(); - } - return daoFactory; - } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/OpenBISHibernateTransactionManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/OpenBISHibernateTransactionManager.java index 63ae6872061106bb7c0f8b11121749e684fb196f..ce534e6d3b4e12a2494366d3d1174a7acc1b3a23 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/OpenBISHibernateTransactionManager.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/OpenBISHibernateTransactionManager.java @@ -27,7 +27,8 @@ import org.springframework.orm.hibernate3.HibernateTransactionManager; import org.springframework.orm.hibernate3.SessionHolder; import org.springframework.transaction.support.DefaultTransactionStatus; -import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException; +import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; /** @@ -42,6 +43,13 @@ public class OpenBISHibernateTransactionManager extends HibernateTransactionMana private static final long serialVersionUID = ServiceVersionHolder.VERSION; + private IDAOFactory daoFactory; + + public OpenBISHibernateTransactionManager(IDAOFactory daoFactory) + { + this.daoFactory = daoFactory; + } + WeakHashMap<Transaction, String> rolledBackTransactions = new WeakHashMap<Transaction, String>(); @@ -55,7 +63,7 @@ public class OpenBISHibernateTransactionManager extends HibernateTransactionMana @Override public Interceptor getEntityInterceptor() throws IllegalStateException, BeansException { - return new EntityVerificationInterceptor(this); + return new EntityVerificationInterceptor(this, daoFactory); } @Override diff --git a/openbis/source/java/genericApplicationContext.xml b/openbis/source/java/genericApplicationContext.xml index e392016928b028544767c6a7a9bf30f0f63cdaa5..62fdc810d6ba7fef29b93267fc499ae8b4302592 100644 --- a/openbis/source/java/genericApplicationContext.xml +++ b/openbis/source/java/genericApplicationContext.xml @@ -19,6 +19,7 @@ <bean id="transaction-manager" class="ch.systemsx.cisd.openbis.generic.server.dataaccess.db.OpenBISHibernateTransactionManager"> + <constructor-arg ref="dao-factory" /> <property name="sessionFactory" ref="hibernate-session-factory" /> <property name="jdbcExceptionTranslator" ref="exception-translator" /> </bean>