[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao ...
Christian Bauer
christian at hibernate.org
Tue Sep 25 10:30:44 EDT 2007
User: cbauer
Date: 07/09/25 10:30:44
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/dao
UserDAO.java UserRoleAccessFactory.java
WikiNodeFactory.java FeedDAO.java NodeDAO.java
Log:
Recommending upgrade of JBoss-bundled Hibernate instead of deploying our own (which caused weird conflicts at runtime)
Revision Changes Path
1.9 +0 -8 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserDAO.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UserDAO.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserDAO.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- UserDAO.java 24 Sep 2007 08:23:19 -0000 1.8
+++ UserDAO.java 25 Sep 2007 14:30:43 -0000 1.9
@@ -29,13 +29,10 @@
protected EntityManager entityManager;
public User findUser(Long userId) {
- entityManager.joinTransaction();
return entityManager.find(User.class, userId);
}
public User findUser(String username, boolean onlyActivated, boolean caseSensitive) {
- entityManager.joinTransaction();
-
StringBuilder query = new StringBuilder("select u from User u where");
if (caseSensitive)
query.append(" u.username = :username");
@@ -55,8 +52,6 @@
}
public User findUserWithActivationCode(String activationCode) {
- entityManager.joinTransaction();
-
StringBuilder query = new StringBuilder("select u from User u where u.activationCode = :activationCode");
try {
return (User) entityManager
@@ -73,7 +68,6 @@
User adminUser = (User) Component.getInstance("adminUser");
- entityManager.joinTransaction();
entityManager.createQuery("update Node n set n.createdBy = :admin where n.createdBy = :user")
.setParameter("admin", entityManager.merge(adminUser))
.setParameter("user", user)
@@ -100,8 +94,6 @@
}
private Criteria prepareExampleCriteria(User exampleUser, String orderByProperty, boolean orderDescending, String... ignoreProperty) {
- entityManager.joinTransaction();
-
Example example = Example.create(exampleUser).enableLike(MatchMode.ANYWHERE).ignoreCase();
for (String s : ignoreProperty) example.excludeProperty(s);
1.6 +0 -6 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserRoleAccessFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UserRoleAccessFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserRoleAccessFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- UserRoleAccessFactory.java 24 Sep 2007 08:23:19 -0000 1.5
+++ UserRoleAccessFactory.java 25 Sep 2007 14:30:44 -0000 1.6
@@ -26,7 +26,6 @@
@Factory(value = "guestUser", scope = ScopeType.SESSION)
public User getGuestUser() {
try {
- entityManager.joinTransaction();
User guestUser =
(User) entityManager
.createQuery("select u from User u left join fetch u.roles where u.username = '"+GUEST_USERNAME+"'")
@@ -47,7 +46,6 @@
@Factory(value = "adminUser", scope = ScopeType.SESSION)
public User getAdminUser() {
try {
- entityManager.joinTransaction();
User adminUser =
(User) entityManager
.createQuery("select u from User u left join fetch u.roles where u.username = '"+ADMIN_USERNAME+"'")
@@ -67,7 +65,6 @@
@Factory(value = "guestRole", scope = ScopeType.SESSION)
public Role getGuestRole() {
try {
- entityManager.joinTransaction();
return (Role) entityManager
.createQuery("select r from Role r where r.accessLevel = '"+GUESTROLE_ACCESSLEVEL+"'")
.getSingleResult();
@@ -79,7 +76,6 @@
@Factory(value = "adminRole", scope = ScopeType.SESSION)
public Role getAdminRole() {
try {
- entityManager.joinTransaction();
return (Role) entityManager
.createQuery("select r from Role r where r.accessLevel = '"+ADMINROLE_ACCESSLEVEL+"'")
.getSingleResult();
@@ -92,7 +88,6 @@
public Role getDefaultRole() {
UserManagementPreferences userPrefs = (UserManagementPreferences) Component.getInstance("userManagementPreferences");
try {
- entityManager.joinTransaction();
return (Role) entityManager
.createQuery("select r from Role r where r.name = '"+userPrefs.getNewUserInRole()+"'")
.getSingleResult();
@@ -118,7 +113,6 @@
@SuppressWarnings({"unchecked"})
public List<Role> getRoles() {
if (roles == null) {
- entityManager.joinTransaction();
roles = (List<Role>) entityManager
.createQuery("select r from Role r order by r.accessLevel desc, r.displayName asc")
.getResultList();
1.12 +0 -5 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiNodeFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeFactory.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- WikiNodeFactory.java 24 Sep 2007 08:23:19 -0000 1.11
+++ WikiNodeFactory.java 25 Sep 2007 14:30:44 -0000 1.12
@@ -33,7 +33,6 @@
@Factory(value = "wikiRoot", scope = ScopeType.PAGE, autoCreate = true)
public Directory loadWikiRoot() {
- entityManager.joinTransaction();
try {
return (Directory) entityManager
.createQuery("select d from Directory d where d.parent is null")
@@ -46,7 +45,6 @@
@Factory(value = "wikiStart", scope = ScopeType.PAGE, autoCreate = true)
public Document loadWikiStart() {
- restrictedEntityManager.joinTransaction();
WikiPreferences wikiPreferences = (WikiPreferences) Component.getInstance("wikiPreferences");
try {
return (Document) restrictedEntityManager
@@ -67,7 +65,6 @@
public Directory loadWikiRootRestricted() {
Directory wikiroot = (Directory) Component.getInstance("wikiRoot");
- restrictedEntityManager.joinTransaction();
try {
return (Directory) restrictedEntityManager
.createQuery("select d from Directory d where d.id = :id")
@@ -82,7 +79,6 @@
@Factory(value = "memberArea", scope = ScopeType.PAGE, autoCreate = true)
public Directory loadMemberArea() {
Long memberAreaId = ((WikiPreferences)Component.getInstance("wikiPreferences")).getMemberAreaId();
- entityManager.joinTransaction();
try {
return (Directory) entityManager
.createQuery("select d from Directory d where d.id = :dirId and d.parent.parent is null")
@@ -100,7 +96,6 @@
@Factory(value = "linkProtocolMap", scope = ScopeType.CONVERSATION, autoCreate = true)
public Map<String, LinkProtocol> loadLinkProtocols() {
- entityManager.joinTransaction();
Map<String, LinkProtocol> linkProtocols = new TreeMap<String, LinkProtocol>();
//noinspection unchecked
List<Object[]> result = entityManager
1.18 +0 -9 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/FeedDAO.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FeedDAO.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/FeedDAO.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- FeedDAO.java 24 Sep 2007 08:23:19 -0000 1.17
+++ FeedDAO.java 25 Sep 2007 14:30:44 -0000 1.18
@@ -39,7 +39,6 @@
@In protected EntityManager restrictedEntityManager;
public List<FeedEntry> findLastFeedEntries(Long feedId, int maxResults) {
- restrictedEntityManager.joinTransaction();
return (List<FeedEntry>) restrictedEntityManager
.createQuery("select fe from Feed f join f.feedEntries fe where f.id = :feedId order by fe.publishedDate desc")
.setParameter("feedId", feedId)
@@ -69,7 +68,6 @@
}
public Feed findFeed(Long feedId) {
- restrictedEntityManager.joinTransaction();
try {
return (Feed) restrictedEntityManager
.createQuery("select f from Feed f where f.id = :id")
@@ -82,7 +80,6 @@
}
public FeedEntry findSiteFeedEntry(Document document) {
- restrictedEntityManager.joinTransaction();
try {
return (FeedEntry) restrictedEntityManager
.createQuery("select fe from Feed f join f.feedEntries fe where f = :feed and fe.document = :document")
@@ -96,8 +93,6 @@
}
public void createFeedEntry(Document document, boolean pushOnSiteFeed) {
- restrictedEntityManager.joinTransaction();
-
Set<Feed> feeds = getAvailableFeeds(document, pushOnSiteFeed);
// Now create a feedentry and link it to all the feeds
@@ -122,8 +117,6 @@
}
public void updateFeedEntry(Document document, boolean pushOnSiteFeed) {
- restrictedEntityManager.joinTransaction();
-
try {
FeedEntry fe = (FeedEntry)restrictedEntityManager.createQuery("select fe from FeedEntry fe where fe.document = :doc")
.setParameter("doc", document).getSingleResult();
@@ -152,8 +145,6 @@
// TODO: Maybe the wiki needs a real maintenance thread at some point... @Observer("Feeds.purgeFeedEntries")
public void purgeOldFeedEntries() {
- restrictedEntityManager.joinTransaction();
-
// Clean up _all_ feed entries that are older than N days
WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
Calendar oldestDate = GregorianCalendar.getInstance();
1.29 +0 -20 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/NodeDAO.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeDAO.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/NodeDAO.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- NodeDAO.java 24 Sep 2007 08:23:19 -0000 1.28
+++ NodeDAO.java 25 Sep 2007 14:30:44 -0000 1.29
@@ -45,12 +45,10 @@
@In protected EntityManager entityManager;
public void makePersistent(Node node) {
- entityManager.joinTransaction();
entityManager.persist(node);
}
public Node findNode(Long nodeId) {
- restrictedEntityManager.joinTransaction();
try {
return (Node) restrictedEntityManager
.createQuery("select n from Node n where n.id = :nodeId")
@@ -68,7 +66,6 @@
}
private Node findNodeInArea(Long areaNumber, String wikiname, EntityManager em) {
- em.joinTransaction();
try {
return (Node) em
@@ -85,8 +82,6 @@
}
public Document findDocumentInArea(Long areaNumber, String wikiname) {
- restrictedEntityManager.joinTransaction();
-
try {
return (Document) restrictedEntityManager
.createQuery("select d from Document d where d.areaNumber = :areaNumber and d.wikiname = :wikiname")
@@ -102,8 +97,6 @@
}
public Directory findDirectoryInArea(Long areaNumber, String wikiname) {
- restrictedEntityManager.joinTransaction();
-
try {
return (Directory) restrictedEntityManager
.createQuery("select d from Directory d where d.areaNumber = :areaNumber and d.wikiname = :wikiname")
@@ -119,8 +112,6 @@
}
public Directory findArea(String wikiname) {
- restrictedEntityManager.joinTransaction();
-
try {
return (Directory) restrictedEntityManager
.createQuery("select d from Directory d where d.parent = :root and d.wikiname = :wikiname")
@@ -136,8 +127,6 @@
}
public Directory findArea(Long areaNumber) {
- restrictedEntityManager.joinTransaction();
-
try {
return (Directory) restrictedEntityManager
.createQuery("select d from Directory d where d.parent = :root and d.areaNumber = :areaNumber")
@@ -214,8 +203,6 @@
}
public Document findDocument(Long documentId) {
- restrictedEntityManager.joinTransaction();
-
try {
return (Document) restrictedEntityManager
.createQuery("select d from Document d where d.id = :id")
@@ -230,8 +217,6 @@
}
public Directory findDirectory(Long directoryId) {
- restrictedEntityManager.joinTransaction();
-
try {
return (Directory) restrictedEntityManager
.createQuery("select d from Directory d where d.id = :id")
@@ -246,8 +231,6 @@
}
public File findFile(Long fileId) {
- restrictedEntityManager.joinTransaction();
-
try {
return (File) restrictedEntityManager
.createQuery("select f from File f where f.id = :id")
@@ -263,7 +246,6 @@
public Document findDefaultDocument(Node directory) {
if (directory == null) return null;
- restrictedEntityManager.joinTransaction();
try {
return (Document) restrictedEntityManager
.createQuery("select doc from Document doc, Directory dir" +
@@ -397,10 +379,8 @@
private Session getSession(boolean restricted) {
if (restricted) {
- restrictedEntityManager.joinTransaction();
return ((Session)((org.jboss.seam.persistence.EntityManagerProxy) restrictedEntityManager).getDelegate());
} else {
- entityManager.joinTransaction();
return ((Session)((org.jboss.seam.persistence.EntityManagerProxy) entityManager).getDelegate());
}
}
More information about the jboss-cvs-commits
mailing list