dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24230
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11833: SmsCommandStore, replaced explicit transaction code with transational annotation
------------------------------------------------------------
revno: 11833
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-29 19:04:34 +0200
message:
SmsCommandStore, replaced explicit transaction code with transational annotation
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java 2013-08-26 03:41:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java 2013-08-29 17:04:34 +0000
@@ -33,10 +33,10 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.message.MessageSender;
-import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
import org.hisp.dhis.user.CurrentUserService;
@@ -45,7 +45,6 @@
import org.hisp.dhis.user.UserSetting;
import org.hisp.dhis.user.UserSettingService;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
/**
* @author Nguyen Kim Lai
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/hibernate/HibernateSMSCommandStore.java 2013-08-29 17:04:34 +0000
@@ -34,7 +34,6 @@
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.sms.parse.ParserType;
@@ -42,6 +41,7 @@
import org.hisp.dhis.smscommand.SMSCommand;
import org.hisp.dhis.smscommand.SMSCommandStore;
import org.springframework.beans.factory.annotation.Required;
+import org.springframework.transaction.annotation.Transactional;
public class HibernateSMSCommandStore
implements SMSCommandStore
@@ -63,26 +63,23 @@
return criteria.list();
}
+ @Transactional
public int save( SMSCommand cmd )
{
- Session s = sessionFactory.getCurrentSession();
- Transaction t = s.beginTransaction();
- s.saveOrUpdate( cmd );
- t.commit();
- s.flush();
+ Session session = sessionFactory.getCurrentSession();
+ session.saveOrUpdate( cmd );
return 0;
}
+ @Transactional
public void save( Set<SMSCode> codes )
{
- Session s = sessionFactory.getCurrentSession();
- Transaction t = s.beginTransaction();
+ Session session = sessionFactory.getCurrentSession();
+
for ( SMSCode x : codes )
{
- s.saveOrUpdate( x );
+ session.saveOrUpdate( x );
}
- t.commit();
- s.flush();
}
public SMSCommand getSMSCommand( int id )
@@ -98,17 +95,17 @@
return null;
}
+ @Transactional
public void delete( SMSCommand cmd )
{
- Session s = sessionFactory.getCurrentSession();
- Transaction t = s.beginTransaction();
+ Session session = sessionFactory.getCurrentSession();
+
for ( SMSCode x : cmd.getCodes() )
{
- s.delete( x );
+ session.delete( x );
}
- s.delete( cmd );
- t.commit();
- s.flush();
+
+ session.delete( cmd );
}
@SuppressWarnings( "unchecked" )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml 2013-08-12 03:29:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCode.hbm.xml 2013-08-29 17:04:34 +0000
@@ -6,7 +6,7 @@
>
<hibernate-mapping package="org.hisp.dhis.smscommand">
<class name="SMSCode" table="smscodes">
- <cache usage="read-write" />
+
<id name="id" column="smscodeid">
<generator class="increment" />
</id>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties 2013-08-23 07:43:51 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/WEB-INF/classes/log4j.properties 2013-08-29 17:04:34 +0000
@@ -25,8 +25,7 @@
# SMS lib logging level
log4j.logger.smslib = INFO
-# Ehcache logging level
-log4j.logger.org.hibernate.cache = ERROR
+# Hibernate logging
log4j.logger.org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog = ERROR
# Spring framework logging level