dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15538
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5650: Dashboard: message - getting exception.
------------------------------------------------------------
revno: 5650
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-01-03 10:50:58 +0700
message:
Dashboard: message - getting exception.
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java
--
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/message/hibernate/HibernateMessageConversationStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/hibernate/HibernateMessageConversationStore.java 2012-01-03 03:50:58 +0000
@@ -33,6 +33,7 @@
import org.hibernate.Query;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.message.MessageConversation;
import org.hisp.dhis.message.MessageConversationStore;
import org.hisp.dhis.user.User;
@@ -44,6 +45,21 @@
public class HibernateMessageConversationStore
extends HibernateIdentifiableObjectStore<MessageConversation> implements MessageConversationStore
{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private StatementBuilder statementBuilder;
+
+ public void setStatementBuilder( StatementBuilder statementBuilder )
+ {
+ this.statementBuilder = statementBuilder;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
public List<MessageConversation> getMessageConversations( User user, Integer first, Integer max )
{
String sql =
@@ -63,14 +79,9 @@
sql += "order by mc.lastupdated desc ";
- if ( first != null )
- {
- sql += "offset " + first + " ";
- }
-
- if ( max != null )
- {
- sql += "limit " + max;
+ if ( first != null && max != null )
+ {
+ sql += statementBuilder.limitRecord( first, max );
}
final List<MessageConversation> conversations = jdbcTemplate.query( sql, new RowMapper<MessageConversation>()
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-12-25 11:16:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2012-01-03 03:50:58 +0000
@@ -215,6 +215,7 @@
<property name="clazz" value="org.hisp.dhis.message.MessageConversation" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="jdbcTemplate" ref="jdbcTemplate" />
+ <property name="statementBuilder" ref="statementBuilder"/>
<property name="cacheable" value="true" />
</bean>
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/StatementBuilder.java 2012-01-03 03:50:58 +0000
@@ -165,4 +165,6 @@
String queryRawDataElementsForOrgUnitBetweenPeriods( Integer orgUnitId, List<Integer> betweenPeriodIds);
String getActivityPlan( int orgunitId, int min, int max );
+
+ String limitRecord( int min, int max );
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/DerbyStatementBuilder.java 2012-01-03 03:50:58 +0000
@@ -346,4 +346,9 @@
"ORDER BY ps.stageinprogram " +
"LIMIT " + max + " OFFSET " + min;
}
+
+ public String limitRecord( int min, int max )
+ {
+ return " LIMIT " + max + " OFFSET " + min;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/H2StatementBuilder.java 2012-01-03 03:50:58 +0000
@@ -368,4 +368,9 @@
"ORDER BY ps.stageinprogram " +
"LIMIT " + max + " OFFSET " + min;
}
+
+ public String limitRecord( int min, int max )
+ {
+ return " LIMIT " + max + " OFFSET " + min;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/MySQLStatementBuilder.java 2012-01-03 03:50:58 +0000
@@ -365,4 +365,9 @@
"ORDER BY ps.stageinprogram " +
"LIMIT " + min + " ," + max;
}
+
+ public String limitRecord( int min, int max )
+ {
+ return " LIMIT " + min + " ," + max;
+ }
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/statementbuilder/PostgreSQLStatementBuilder.java 2012-01-03 03:50:58 +0000
@@ -365,4 +365,10 @@
"ORDER BY ps.stageinprogram " +
"LIMIT " + max + " OFFSET " + min;
}
+
+
+ public String limitRecord( int min, int max )
+ {
+ return " LIMIT " + max + " OFFSET " + min;
+ }
}