[seam-commits] Seam SVN: r10212 - in trunk/examples/wiki/src: main/org/jboss/seam/wiki/core/dao and 4 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Mar 25 09:30:03 EDT 2009
Author: christian.bauer at jboss.com
Date: 2009-03-25 09:30:03 -0400 (Wed, 25 Mar 2009)
New Revision: 10212
Added:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/NativeQueries.hbm.xml
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentLastComment.java
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/DatabaseObjects.hbm.xml
trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumDAO.java
trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/FAQData.dbunit.xml
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/ForumData.dbunit.xml
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/Commenting.java
Log:
JBSEAM-3913, improved forum query performance
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2009-03-25 13:30:03 UTC (rev 10212)
@@ -174,6 +174,7 @@
remove();
getEntityManager().clear();
+ Events.instance().raiseEvent("Comment.removed");
Events.instance().raiseEvent("Comment.commentListRefresh");
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHome.java 2009-03-25 13:30:03 UTC (rev 10212)
@@ -10,9 +10,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.international.Messages;
import org.jboss.seam.international.StatusMessages;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.*;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.wiki.core.action.prefs.CommentsPreferences;
import org.jboss.seam.wiki.core.action.prefs.DocumentEditorPreferences;
@@ -431,4 +429,12 @@
public WikiTextEditor getTextEditor() {
return textEditor;
}
+
+ /* TODO: Performance Optimizations */
+
+ @org.jboss.seam.annotations.Observer(value = {"Comment.persisted", "Comment.removed"}, create = false)
+ public void updateLastComment() {
+ getWikiNodeDAO().updateWikiDocumentLastComment(getInstance());
+ getEntityManager().flush();
+ }
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeDAO.java 2009-03-25 13:30:03 UTC (rev 10212)
@@ -659,6 +659,37 @@
nestedSetQuery.list(); // Append all children hierarchically to the transformers rootWrapper
}
+ public void updateWikiDocumentLastComment(WikiDocument document) {
+ // TODO: This probably is vulnerable to a race condition if we don't lock the whole WIKI_DOCUMENT_LAST_COMMENT table
+
+ Long lastCommentId = (Long)
+ getSession(true).getNamedQuery("findLastCommentOfDocument")
+ .setParameter("documentId", document.getId())
+ .setComment("Finding last comment of document: " + document.getId())
+ .uniqueResult();
+
+ WikiComment lastComment = null;
+ if (lastCommentId!= null) {
+ lastComment = restrictedEntityManager.find(WikiComment.class, lastCommentId);
+ }
+
+ WikiDocumentLastComment existingLastCommentEntry
+ = restrictedEntityManager.find(WikiDocumentLastComment.class, document.getId());
+
+ if (existingLastCommentEntry != null && lastComment == null) {
+ restrictedEntityManager.remove(existingLastCommentEntry);
+ } else if (existingLastCommentEntry != null) {
+ existingLastCommentEntry.setLastCommentId(lastComment.getId());
+ existingLastCommentEntry.setLastCommentCreatedOn(lastComment.getCreatedOn());
+ } else if (lastComment != null){
+ existingLastCommentEntry = new WikiDocumentLastComment();
+ existingLastCommentEntry.setDocumentId(document.getId());
+ existingLastCommentEntry.setLastCommentId(lastComment.getId());
+ existingLastCommentEntry.setLastCommentCreatedOn(lastComment.getCreatedOn());
+ restrictedEntityManager.persist(existingLastCommentEntry);
+ }
+ }
+
private Session getSession(boolean restricted) {
if (restricted) {
return ((Session)((org.jboss.seam.persistence.EntityManagerProxy) restrictedEntityManager).getDelegate());
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/DatabaseObjects.hbm.xml
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/DatabaseObjects.hbm.xml 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/DatabaseObjects.hbm.xml 2009-03-25 13:30:03 UTC (rev 10212)
@@ -46,6 +46,14 @@
<dialect-scope name="org.hibernate.dialect.HSQLDialect"/>
</database-object>
+ <database-object>
+ <create>
+ alter table WIKI_DOCUMENT_LAST_COMMENT add constraint FK_WIKI_DOCUMENT_LAST_COMMENT_DOCUMENT_ID foreign key (WIKI_DOCUMENT_ID) references WIKI_DOCUMENT (NODE_ID) on delete cascade;
+ </create>
+ <drop/>
+ <dialect-scope name="org.hibernate.dialect.HSQLDialect"/>
+ </database-object>
+
<!-- ############################### MySQL ############################### -->
@@ -96,6 +104,14 @@
<database-object>
<create>
+ alter table WIKI_DOCUMENT_LAST_COMMENT add index FK_WIKI_DOCUMENT_LAST_COMMENT_DOCUMENT_ID (WIKI_DOCUMENT_ID), add constraint FK_WIKI_DOCUMENT_LAST_COMMENT_DOCUMENT_ID foreign key (WIKI_DOCUMENT_ID) references WIKI_DOCUMENT (NODE_ID) on delete cascade;
+ </create>
+ <drop/>
+ <dialect-scope name="org.jboss.seam.wiki.util.WikiMySQL5HibernateDialect"/>
+ </database-object>
+
+ <database-object>
+ <create>
create index IDX_PREFERENCE_ENTITY_NAME on PREFERENCE (ENTITY_NAME)
</create>
<drop>
Added: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/NativeQueries.hbm.xml
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/NativeQueries.hbm.xml (rev 0)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/NativeQueries.hbm.xml 2009-03-25 13:30:03 UTC (rev 10212)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <sql-query name="findLastCommentOfDocument">
+ <return-scalar column="LAST_COMMENT_ID" type="long"/>
+ select
+ ct3.NODE_ID as LAST_COMMENT_ID
+ from WIKI_COMMENT ct
+ inner join WIKI_NODE ct1 on ct.NODE_ID = ct1.NODE_ID
+ inner join WIKI_COMMENT ct2 on ct2.NS_THREAD in (ct.NS_THREAD)
+ inner join WIKI_NODE ct3 on ct2.NODE_ID = ct3.NODE_ID,
+ WIKI_NODE doc0
+ inner join WIKI_DOCUMENT doc1 on doc0.NODE_ID = doc1.NODE_ID
+ where
+ ct1.PARENT_NODE_ID = :documentId
+ order by
+ ct3.CREATED_ON desc
+ limit 1
+ </sql-query>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentLastComment.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentLastComment.java (rev 0)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/model/WikiDocumentLastComment.java 2009-03-25 13:30:03 UTC (rev 10212)
@@ -0,0 +1,57 @@
+package org.jboss.seam.wiki.core.model;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * A not-so-pretty denormalization and duplication of data, so aggregation queries
+ * can execute faster on nested set trees.
+ *
+ * @author Christian Bauer
+ */
+ at Entity
+ at Table(
+ name = "WIKI_DOCUMENT_LAST_COMMENT",
+ uniqueConstraints = {
+ @UniqueConstraint(columnNames = {"WIKI_DOCUMENT_ID", "LAST_COMMENT_ID"})
+ }
+)
+
+public class WikiDocumentLastComment {
+
+ @Id
+ @Column(name = "WIKI_DOCUMENT_ID", nullable = false)
+ private Long documentId;
+
+ @Column(name = "LAST_COMMENT_ID", nullable = false)
+ protected Long lastCommentId;
+
+ @Column(name = "LAST_COMMENT_CREATED_ON", nullable = false)
+ protected Date lastCommentCreatedOn;
+
+ public WikiDocumentLastComment() {}
+
+ public Long getDocumentId() {
+ return documentId;
+ }
+
+ public void setDocumentId(Long documentId) {
+ this.documentId = documentId;
+ }
+
+ public Long getLastCommentId() {
+ return lastCommentId;
+ }
+
+ public void setLastCommentId(Long lastCommentId) {
+ this.lastCommentId = lastCommentId;
+ }
+
+ public Date getLastCommentCreatedOn() {
+ return lastCommentCreatedOn;
+ }
+
+ public void setLastCommentCreatedOn(Date lastCommentCreatedOn) {
+ this.lastCommentCreatedOn = lastCommentCreatedOn;
+ }
+}
Modified: trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumDAO.java
===================================================================
--- trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumDAO.java 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumDAO.java 2009-03-25 13:30:03 UTC (rev 10212)
@@ -119,22 +119,22 @@
}
// Append last reply WikiComment
- getSession(true).getNamedQuery("forumLastReply")
- .setParameter("parentDirId", forumsDirectory.getId())
- .setParameter("readAccessLevel", currentAccessLevel)
- .setComment("Finding last replies for all forums")
- .setResultTransformer(
- new ResultTransformer() {
- public Object transformTuple(Object[] result, String[] strings) {
- if (forumInfoMap.containsKey((Long)result[0]))
- forumInfoMap.get( (Long)result[0] ).setLastComment( (WikiComment)result[1] );
- return null;
- }
- public List transformList(List list) { return list; }
- }
- )
- .list();
-
+ for (final Long forumId : forumInfoMap.keySet()) {
+ getSession(true).getNamedQuery("forumLastReply")
+ .setParameter("parentDirId", forumId)
+ .setParameter("readAccessLevel", currentAccessLevel)
+ .setComment("Finding last replies for forum : " + forumId)
+ .setResultTransformer(
+ new ResultTransformer() {
+ public Object transformTuple(Object[] result, String[] strings) {
+ forumInfoMap.get(forumId).setLastComment( (WikiComment)result[0] );
+ return null;
+ }
+ public List transformList(List list) { return list; }
+ }
+ )
+ .list();
+ }
return forumInfoMap;
}
Modified: trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml
===================================================================
--- trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/ForumQueries.hbm.xml 2009-03-25 13:30:03 UTC (rev 10212)
@@ -97,11 +97,8 @@
</sql-query>
<sql-query name="forumLastReply">
- <return-scalar column="FORUM_ID" type="long"/>
<return class="org.jboss.seam.wiki.core.model.WikiComment"/>
select
- dir0.NODE_ID as FORUM_ID,
-
c1.NODE_ID as NODE_ID,
c1.OBJ_VERSION as OBJ_VERSION,
c1.RATING as RATING,
@@ -126,30 +123,22 @@
c0.NS_LEFT as NS_LEFT,
c0.NS_RIGHT as NS_RIGHT,
c0.NS_THREAD as NS_THREAD
- from
- WIKI_NODE dir0,
- WIKI_NODE c1 inner join WIKI_COMMENT c0 on c1.NODE_ID = c0.NODE_ID
- where
- dir0.PARENT_NODE_ID = :parentDirId
- and
- dir0.READ_ACCESS_LEVEL <= :readAccessLevel
- and
- c1.CREATED_ON = (
- select max(ct3.CREATED_ON)
- from
- WIKI_NODE doc0
- inner join WIKI_DOCUMENT doc1 on doc0.NODE_ID = doc1.NODE_ID
- and (doc1.HEADER_MACROS like '%forumPosting%' or doc1.HEADER_MACROS like '%forumStickyPosting%')
- inner join WIKI_NODE ct0 on doc1.NODE_ID = ct0.PARENT_NODE_ID
- inner join WIKI_COMMENT ct1 on ct0.NODE_ID = ct1.NODE_ID
- inner join WIKI_COMMENT ct2 on ct2.NS_THREAD in (ct1.NS_THREAD)
- inner join WIKI_NODE ct3 on ct2.NODE_ID = ct3.NODE_ID
- where
- doc0.PARENT_NODE_ID= dir0.NODE_ID
- and
- doc0.READ_ACCESS_LEVEL <= :readAccessLevel
- )
-
+ from
+ WIKI_NODE doc0
+ inner join WIKI_DOCUMENT doc1 on doc0.NODE_ID = doc1.NODE_ID
+ and (doc1.HEADER_MACROS like '%forumPosting%' or doc1.HEADER_MACROS like '%forumStickyPosting%')
+ inner join WIKI_DOCUMENT_LAST_COMMENT lc on lc.WIKI_DOCUMENT_ID = doc1.NODE_ID,
+ WIKI_NODE c1
+ inner join WIKI_COMMENT c0 on c0.NODE_ID = c1.NODE_ID
+ where
+ doc0.PARENT_NODE_ID = :parentDirId
+ and
+ doc0.READ_ACCESS_LEVEL <= :readAccessLevel
+ and
+ c0.NODE_ID = lc.LAST_COMMENT_ID
+ order by
+ lc.LAST_COMMENT_CREATED_ON desc
+ limit 1
</sql-query>
<query name="forumUnreadTopics"><![CDATA[
@@ -246,12 +235,9 @@
WIKI_NODE d0
inner join WIKI_DOCUMENT d2 on d0.NODE_ID = d2.NODE_ID and (d2.HEADER_MACROS like '%forumPosting%' or d2.HEADER_MACROS like '%forumStickyPosting%')
left outer join WIKI_NODE c0
- on c0.CREATED_ON = (
- select max(ct3.CREATED_ON) from WIKI_COMMENT ct
- inner join WIKI_NODE ct1 on ct.NODE_ID = ct1.NODE_ID
- inner join WIKI_COMMENT ct2 on ct2.NS_THREAD in (ct.NS_THREAD)
- inner join WIKI_NODE ct3 on ct2.NODE_ID = ct3.NODE_ID
- where ct1.PARENT_NODE_ID = d2.NODE_ID
+ on c0.NODE_ID = (
+ select lc.LAST_COMMENT_ID from WIKI_DOCUMENT_LAST_COMMENT lc
+ where lc.WIKI_DOCUMENT_ID = d2.NODE_ID
)
where
d0.READ_ACCESS_LEVEL <= :readAccessLevel and d0.PARENT_NODE_ID = :parentNodeId
@@ -354,18 +340,9 @@
doc0.NODE_ID in (:topicIds)
and c0.NS_THREAD in (ct1.NS_THREAD)
and cl0.NODE_ID = (
- select ct3.NODE_ID
- from WIKI_COMMENT ct
- inner join WIKI_NODE ct1 on ct.NODE_ID = ct1.NODE_ID
- inner join WIKI_COMMENT ct2 on ct2.NS_THREAD in (ct.NS_THREAD)
- inner join WIKI_NODE ct3 on ct2.NODE_ID = ct3.NODE_ID,
- WIKI_NODE d0
- inner join WIKI_DOCUMENT d1 on d0.NODE_ID = d1.NODE_ID
- where
- d0.NODE_ID = doc0.NODE_ID and
- ct1.PARENT_NODE_ID = d0.NODE_ID
- order by ct3.CREATED_ON desc
- limit 1
+ select lc.LAST_COMMENT_ID
+ from WIKI_DOCUMENT_LAST_COMMENT lc
+ where lc.WIKI_DOCUMENT_ID = doc0.NODE_ID
)
group by
cl1.NODE_ID, cl1.OBJ_VERSION, cl1.RATING, cl1.AREA_NR, cl1.NAME, cl1.WIKINAME, cl1.MESSAGE_ID, cl1.CREATED_ON, cl1.CREATED_BY_USER_ID, cl1.LAST_MODIFIED_ON,
Modified: trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/FAQData.dbunit.xml
===================================================================
--- trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/FAQData.dbunit.xml 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/FAQData.dbunit.xml 2009-03-25 13:30:03 UTC (rev 10212)
@@ -134,4 +134,9 @@
FROM_USER_NAME="My Anonymous Name" FROM_USER_EMAIL="foo at bar.baz.somemoretext.tld" FROM_USER_HOMEPAGE="http://foo.bar.baz/foo/bar?foo=123"
NS_LEFT="1" NS_RIGHT="2" NS_THREAD="309"/>
+ <WIKI_DOCUMENT_LAST_COMMENT
+ WIKI_DOCUMENT_ID="308"
+ LAST_COMMENT_CREATED_ON="2006-09-23 13:45:00"
+ LAST_COMMENT_ID="309"/>
+
</dataset>
\ No newline at end of file
Modified: trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/ForumData.dbunit.xml
===================================================================
--- trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/ForumData.dbunit.xml 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/ForumData.dbunit.xml 2009-03-25 13:30:03 UTC (rev 10212)
@@ -124,6 +124,11 @@
FROM_USER_NAME="Regular Member" FROM_USER_EMAIL="[NULL]" FROM_USER_HOMEPAGE="[NULL]"
NS_LEFT="2" NS_RIGHT="3" NS_THREAD="105"/>
+ <WIKI_DOCUMENT_LAST_COMMENT
+ WIKI_DOCUMENT_ID="104"
+ LAST_COMMENT_CREATED_ON="2007-04-10 10:00:00"
+ LAST_COMMENT_ID="106"/>
+
<!-- Second (sticky) posting -->
<WIKI_NODE
NODE_ID="107" OBJ_VERSION="0" RATING="0" PARENT_NODE_ID="102"
@@ -156,6 +161,11 @@
FROM_USER_NAME="Regular Member" FROM_USER_EMAIL="[NULL]" FROM_USER_HOMEPAGE="[NULL]"
NS_LEFT="1" NS_RIGHT="2" NS_THREAD="108"/>
+ <WIKI_DOCUMENT_LAST_COMMENT
+ WIKI_DOCUMENT_ID="107"
+ LAST_COMMENT_CREATED_ON="2007-04-04 08:01:00"
+ LAST_COMMENT_ID="108"/>
+
<!-- Third posting
<WIKI_NODE
NODE_ID="112" OBJ_VERSION="0" RATING="0" PARENT_NODE_ID="102"
Modified: trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml
===================================================================
--- trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml 2009-03-25 13:30:03 UTC (rev 10212)
@@ -318,7 +318,7 @@
<WIKI_NODE
NODE_ID="12" OBJ_VERSION="0" RATING="0" PARENT_NODE_ID="10"
AREA_NR="3" NAME="One.Comment1196729874870" WIKINAME="OneComment.1196729874870"
- CREATED_ON="2006-09-25 13:45:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
+ CREATED_ON="2006-09-25 13:46:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
READ_ACCESS_LEVEL="0" WRITE_ACCESS_LEVEL="0" WRITE_PROTECTED="false"/>
<WIKI_COMMENT
NODE_ID="12"
@@ -329,7 +329,7 @@
<WIKI_NODE
NODE_ID="13" OBJ_VERSION="0" RATING="0" PARENT_NODE_ID="12"
AREA_NR="3" NAME="One.Comment11967293211870" WIKINAME="OneComment11967293211870"
- CREATED_ON="2006-09-26 13:45:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
+ CREATED_ON="2006-09-26 13:47:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
READ_ACCESS_LEVEL="0" WRITE_ACCESS_LEVEL="0" WRITE_PROTECTED="false"/>
<WIKI_COMMENT
NODE_ID="13"
@@ -340,7 +340,7 @@
<WIKI_NODE
NODE_ID="14" OBJ_VERSION="0" RATING="0" PARENT_NODE_ID="6"
AREA_NR="3" NAME="One.Comment11967293211830" WIKINAME="OneComment11967293211830"
- CREATED_ON="2006-09-27 13:45:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
+ CREATED_ON="2006-09-27 13:48:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
READ_ACCESS_LEVEL="0" WRITE_ACCESS_LEVEL="0" WRITE_PROTECTED="false"/>
<WIKI_COMMENT
NODE_ID="14"
@@ -351,7 +351,7 @@
<WIKI_NODE
NODE_ID="15" OBJ_VERSION="0" RATING="0" PARENT_NODE_ID="14"
AREA_NR="3" NAME="One.Comment119672932118230" WIKINAME="OneComment119672932118230"
- CREATED_ON="2006-09-28 13:45:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
+ CREATED_ON="2006-09-28 13:49:00" CREATED_BY_USER_ID="2" LAST_MODIFIED_ON="[NULL]" LAST_MODIFIED_BY_USER_ID="[NULL]"
READ_ACCESS_LEVEL="0" WRITE_ACCESS_LEVEL="0" WRITE_PROTECTED="false"/>
<WIKI_COMMENT
NODE_ID="15"
@@ -359,6 +359,10 @@
FROM_USER_NAME="My Anonymous Name" FROM_USER_EMAIL="foo at bar.baz.somemoretext.tld" FROM_USER_HOMEPAGE="http://foo.bar.baz/foo/bar?foo=123"
NS_LEFT="2" NS_RIGHT="3" NS_THREAD="14"/>
+ <WIKI_DOCUMENT_LAST_COMMENT
+ WIKI_DOCUMENT_ID="6"
+ LAST_COMMENT_CREATED_ON="2006-09-28 13:49:00"
+ LAST_COMMENT_ID="15"/>
<WIKI_DOCUMENT_HISTORY
FILE_HISTORY_ID="1" FILE_ID="6" FILE_REVISION="0"
Modified: trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/Commenting.java
===================================================================
--- trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/Commenting.java 2009-03-25 09:02:59 UTC (rev 10211)
+++ trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/editing/Commenting.java 2009-03-25 13:30:03 UTC (rev 10212)
@@ -9,15 +9,14 @@
import org.dbunit.operation.DatabaseOperation;
import org.jboss.seam.wiki.core.action.CommentHome;
import org.jboss.seam.wiki.core.action.CommentQuery;
-import org.jboss.seam.wiki.core.model.User;
-import org.jboss.seam.wiki.core.model.WikiDocument;
-import org.jboss.seam.wiki.core.model.WikiDirectory;
-import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.*;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.test.util.DBUnitSeamTest;
import org.jboss.seam.contexts.Contexts;
import org.testng.annotations.Test;
+import javax.persistence.EntityManager;
+
public class Commenting extends DBUnitSeamTest {
protected void prepareDBUnitOperations() {
@@ -74,7 +73,11 @@
assert commentQuery.getComments().get(6).getName().matches("One\\.Comment[0-9]+");
assert !commentQuery.getComments().get(6).getWikiname().contains(" ");
-
+
+ EntityManager em = (EntityManager)getInstance("entityManager");
+ WikiDocumentLastComment lastComment = em.find(WikiDocumentLastComment.class, 6l);
+ assert lastComment != null;
+ assert lastComment.getLastCommentId().equals(commentQuery.getComments().get(6).getId());
}
}.run();
@@ -131,6 +134,10 @@
assert commentQuery.getComments().get(6).getName().matches("One\\.Comment[0-9]+");
assert !commentQuery.getComments().get(6).getWikiname().contains(" ");
+ EntityManager em = (EntityManager)getInstance("entityManager");
+ WikiDocumentLastComment lastComment = em.find(WikiDocumentLastComment.class, 6l);
+ assert lastComment != null;
+ assert lastComment.getLastCommentId().equals(commentQuery.getComments().get(6).getId());
}
}.run();
@@ -152,7 +159,7 @@
}
protected void invokeApplication() throws Exception {
- invokeMethod("#{commentHome.remove(12)}");
+ invokeMethod("#{commentHome.remove(14)}");
}
protected void renderResponse() throws Exception {
@@ -162,10 +169,16 @@
assert commentQuery.getComments().get(0).getLevel().equals(1l);
assert commentQuery.getComments().get(1).getId().equals(11l);
assert commentQuery.getComments().get(1).getLevel().equals(2l);
- assert commentQuery.getComments().get(2).getId().equals(14l);
- assert commentQuery.getComments().get(2).getLevel().equals(1l);
- assert commentQuery.getComments().get(3).getId().equals(15l);
- assert commentQuery.getComments().get(3).getLevel().equals(2l);
+ assert commentQuery.getComments().get(2).getId().equals(12l);
+ assert commentQuery.getComments().get(2).getLevel().equals(2l);
+ assert commentQuery.getComments().get(3).getId().equals(13l);
+ assert commentQuery.getComments().get(3).getLevel().equals(3l);
+
+ EntityManager em = (EntityManager)getInstance("entityManager");
+ WikiDocumentLastComment lastComment = em.find(WikiDocumentLastComment.class, 6l);
+ assert lastComment != null;
+ assert lastComment.getLastCommentId().equals(13l);
+
}
}.run();
More information about the seam-commits
mailing list