roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r511668 - in /incubator/roller/branches/roller_4.0: components/core/src/java/org/apache/roller/business/jpa/ metadata/database/ src/org/apache/roller/business/jpa/ tools/roller-core/
Date Mon, 26 Feb 2007 00:18:54 GMT
Author: snoopdave
Date: Sun Feb 25 16:18:51 2007
New Revision: 511668

URL: http://svn.apache.org/viewvc?view=rev&rev=511668
Log:
Added getNamedUpdate() for update queries, which should not have FlushModeType.COMMIT

Modified:
    incubator/roller/branches/roller_4.0/components/core/src/java/org/apache/roller/business/jpa/JPAPersistenceStrategy.java
    incubator/roller/branches/roller_4.0/metadata/database/droptables.sql
    incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAAutoPingManagerImpl.java
    incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAPingTargetManagerImpl.java
    incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPARefererManagerImpl.java
    incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAThreadManagerImpl.java
    incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
    incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
    incubator/roller/branches/roller_4.0/tools/roller-core/roller-core.jar

Modified: incubator/roller/branches/roller_4.0/components/core/src/java/org/apache/roller/business/jpa/JPAPersistenceStrategy.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/components/core/src/java/org/apache/roller/business/jpa/JPAPersistenceStrategy.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/components/core/src/java/org/apache/roller/business/jpa/JPAPersistenceStrategy.java
(original)
+++ incubator/roller/branches/roller_4.0/components/core/src/java/org/apache/roller/business/jpa/JPAPersistenceStrategy.java
Sun Feb 25 16:18:51 2007
@@ -69,8 +69,7 @@
         Properties emfProps = loadPropertiesFromResourceName(
                 "JPAEMF.properties", getContextClassLoader());
         try {
-            this.emf =
-                    Persistence.createEntityManagerFactory(puName, emfProps);
+            this.emf = Persistence.createEntityManagerFactory(puName, emfProps);
         } catch (PersistenceException pe) {
             logger.error("ERROR: creating entity manager", pe);
             throw new RollerException(pe);
@@ -230,7 +229,7 @@
     }
     
     /**
-     * Create query.
+     * Get named query with FlushModeType.COMMIT
      * @param clazz the class of instances to find
      * @param queryName the name of the query
      * @throws org.apache.roller.RollerException on any error
@@ -239,12 +238,13 @@
     throws RollerException {
         EntityManager em = getEntityManager(false);
         Query q = em.createNamedQuery(queryName);
+        // Never flush for queries. Roller code assumes this behavior
         q.setFlushMode(FlushModeType.COMMIT);
         return q;
     }
     
     /**
-     * Create query from queryString
+     * Create query from queryString with FlushModeType.COMMIT
      * @param queryString the quuery
      * @throws org.apache.roller.RollerException on any error
      */
@@ -252,7 +252,21 @@
     throws RollerException {
         EntityManager em = getEntityManager(false);
         Query q = em.createQuery(queryString);
+        // Never flush for queries. Roller code assumes this behavior
         q.setFlushMode(FlushModeType.COMMIT);
+        return q;
+    }
+    
+    /**
+     * Get named update query with default flush mode
+     * @param clazz the class of instances to find
+     * @param queryName the name of the query
+     * @throws org.apache.roller.RollerException on any error
+     */
+    public Query getNamedUpdate(String queryName)
+    throws RollerException {
+        EntityManager em = getEntityManager(false);
+        Query q = em.createNamedQuery(queryName);
         return q;
     }
     

Modified: incubator/roller/branches/roller_4.0/metadata/database/droptables.sql
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/metadata/database/droptables.sql?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/metadata/database/droptables.sql (original)
+++ incubator/roller/branches/roller_4.0/metadata/database/droptables.sql Sun Feb 25 16:18:51
2007
@@ -15,11 +15,13 @@
 -- directory of this distribution.
 
 -- planet tables
+drop table planet_id_table;
 drop table rag_config;
 drop table rag_group;
 drop table rag_subscription;
 drop table rag_entry;
 drop table rag_group_subscription;
+drop table rag_planet;
 
 -- non-associated tables
 drop table newsfeed;
@@ -40,6 +42,7 @@
 drop table folderassoc;
 
 -- core services tables
+drop table roller_id_table;
 drop table roller_hitcounts;
 drop table roller_comment;
 drop table roller_weblogentrytag;

Modified: incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAAutoPingManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAAutoPingManagerImpl.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAAutoPingManagerImpl.java
(original)
+++ incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAAutoPingManagerImpl.java
Sun Feb 25 16:18:51 2007
@@ -74,7 +74,7 @@
 
     public void removeAutoPing(PingTargetData pingTarget, WebsiteData website)
             throws RollerException {
-        Query q = strategy.getNamedQuery("AutoPingData.removeByPingTarget&Website");
+        Query q = strategy.getNamedUpdate("AutoPingData.removeByPingTarget&Website");
         q.setParameter(1, pingTarget);
         q.setParameter(2, website);
         q.executeUpdate();

Modified: incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAPingTargetManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAPingTargetManagerImpl.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAPingTargetManagerImpl.java
(original)
+++ incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAPingTargetManagerImpl.java
Sun Feb 25 16:18:51 2007
@@ -69,19 +69,19 @@
     private void removePingTargetContents(PingTargetData ping) 
             throws RollerException {
         // Remove the website's ping queue entries
-        Query q = strategy.getNamedQuery("PingQueueEntryData.removeByPingTarget");
+        Query q = strategy.getNamedUpdate("PingQueueEntryData.removeByPingTarget");
         q.setParameter(1, ping);
         q.executeUpdate();
         
         // Remove the website's auto ping configurations
-        q = strategy.getNamedQuery("AutoPingData.removeByPingTarget");
+        q = strategy.getNamedUpdate("AutoPingData.removeByPingTarget");
         q.setParameter(1, ping);
         q.executeUpdate();
     }
 
     public void removeAllCustomPingTargets()
             throws RollerException {
-        Query q = strategy.getNamedQuery(
+        Query q = strategy.getNamedUpdate(
             "PingTargetData.removeByWebsiteNotNull");
         q.executeUpdate();
     }

Modified: incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPARefererManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPARefererManagerImpl.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPARefererManagerImpl.java
(original)
+++ incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPARefererManagerImpl.java
Sun Feb 25 16:18:51 2007
@@ -88,7 +88,7 @@
      */
     public void clearReferrers() throws RollerException {
         clearDayHits();
-        Query q = strategy.getNamedQuery("RefererData.removeByNullOrEmptyExcerpt");
+        Query q = strategy.getNamedUpdate("RefererData.removeByNullOrEmptyExcerpt");
         q.executeUpdate();
     }
 
@@ -97,7 +97,7 @@
      */
     public void clearReferrers(WebsiteData website) throws RollerException {
         clearDayHitsByWebsite(website);
-        Query q = strategy.getNamedQuery("RefererData.removeByNullOrEmptyExcerpt&Website");
+        Query q = strategy.getNamedUpdate("RefererData.removeByNullOrEmptyExcerpt&Website");
         q.setParameter(1, website);
         q.executeUpdate();
     }
@@ -630,12 +630,12 @@
     public void release() {}
     
     protected void clearDayHits() throws RollerException {
-        Query query = strategy.getNamedQuery("RefererData.clearDayHits");
+        Query query = strategy.getNamedUpdate("RefererData.clearDayHits");
         query.executeUpdate();
     }
 
     protected void clearDayHitsByWebsite(WebsiteData website) throws RollerException {
-        Query query = strategy.getNamedQuery("RefererData.clearDayHitsByWebsite");
+        Query query = strategy.getNamedUpdate("RefererData.clearDayHitsByWebsite");
         query.setParameter(1, website);
         query.executeUpdate();
     }

Modified: incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAThreadManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAThreadManagerImpl.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAThreadManagerImpl.java
(original)
+++ incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAThreadManagerImpl.java
Sun Feb 25 16:18:51 2007
@@ -101,7 +101,7 @@
 
     protected boolean acquireLeaseInDatabase(RollerTask task, TaskLockData taskLock,
             long leaseExpireTime) throws RollerException {
-        Query q = strategy.getNamedQuery(
+        Query q = strategy.getNamedUpdate(
             "TaskLockData.updateClient&Timeacquired&TimeleasedByName&Timeacquired");
         q.setParameter(1, task.getClientId());
         q.setParameter(2, Integer.valueOf(task.getLeaseTime()));
@@ -149,7 +149,7 @@
 
     protected boolean releaseLeaseInDatabase(RollerTask task)
             throws RollerException {
-        Query q = strategy.getNamedQuery(
+        Query q = strategy.getNamedUpdate(
             "TaskLockData.updateTimeLeasedByName&Client");
         q.setParameter(1, Integer.valueOf(task.getInterval()));
         q.setParameter(2, task.getName());

Modified: incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
(original)
+++ incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAUserManagerImpl.java
Sun Feb 25 16:18:51 2007
@@ -116,13 +116,13 @@
         updateTagAggregates(tags);
         
         // delete all weblog tag aggregates
-        Query removeAggs= strategy.getNamedQuery(
+        Query removeAggs= strategy.getNamedUpdate(
                 "WeblogEntryTagAggregateData.removeByWeblog");
         removeAggs.setParameter(1, website);
         removeAggs.executeUpdate();
         
         // delete all bad counts
-        Query removeCounts = strategy.getNamedQuery(
+        Query removeCounts = strategy.getNamedUpdate(
                 "WeblogEntryTagAggregateData.removeByTotalLessEqual");
         removeCounts.setParameter(1, new Integer(0));
         removeCounts.executeUpdate();
@@ -215,7 +215,7 @@
     protected void updateTagAggregates(List tags) throws RollerException {
         for(Iterator iter = tags.iterator(); iter.hasNext();) {
             TagStat stat = (TagStat) iter.next();
-            Query query = strategy.getNamedQuery(
+            Query query = strategy.getNamedUpdate(
                     "WeblogEntryTagAggregateData.updateMinusFromTotalByName&WeblogNull");
             query.setParameter(1, Integer.valueOf(stat.getCount()));
             query.setParameter(2, stat.getName());
@@ -541,6 +541,7 @@
         int size = 0;
         StringBuffer queryString = new StringBuffer();
         StringBuffer whereClause = new StringBuffer();
+        
         queryString.append("SELECT w FROM WebsiteData w WHERE ");
                      
         if (startDate != null) {
@@ -562,16 +563,13 @@
             params.add(size++, active);
             whereClause.append(" w.active = ?" + size);
         }
-        if (user != null) {
-            
-            whereClause.append(" AND EXISTS (SELECT p from PermissionsData p where p.website
= w ");
+        if (user != null) {    
+            whereClause.append(" AND EXISTS (SELECT p from PermissionsData p WHERE p.website
= w ");
             params.add(size++, user);         
             whereClause.append("    AND p.user = ?" + size);
             params.add(size++, Boolean.FALSE);
-            whereClause.append("    AND p.pending = ?" + size + ")");
-            
+            whereClause.append("    AND p.pending = ?" + size + ")");   
         }
-
         whereClause.append(" ORDER BY w.dateCreated DESC");
         
         query = strategy.getDynamicQuery(queryString.toString() + whereClause.toString());

Modified: incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
--- incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
(original)
+++ incubator/roller/branches/roller_4.0/src/org/apache/roller/business/jpa/JPAWeblogManagerImpl.java
Sun Feb 25 16:18:51 2007
@@ -1181,7 +1181,7 @@
         }
         
         // TODO: Non-standard JPA bulk update, using parameter values in set clause
-        Query q = strategy.getNamedQuery(
+        Query q = strategy.getNamedUpdate(
                 "WeblogEntryData.updateAllowComments&CommentDaysByWebsite");
         q.setParameter(1, website.getDefaultAllowComments());
         q.setParameter(2, new Integer(website.getDefaultCommentDays()));
@@ -1411,7 +1411,7 @@
             weblogTagData.setLastUsed(lastUsed);
             strategy.store(weblogTagData);
         } else if(weblogTagData != null) {
-            Query update = strategy.getNamedQuery(
+            Query update = strategy.getNamedUpdate(
                     "WeblogEntryTagAggregateData.updateAddToTotalByName&Weblog");
             update.setParameter(1, new Long(amount));
             update.setParameter(2, weblogTagData.getName());
@@ -1425,7 +1425,7 @@
             siteTagData.setLastUsed(lastUsed);
             strategy.store(siteTagData);
         } else if(siteTagData != null) {
-            Query update = strategy.getNamedQuery(
+            Query update = strategy.getNamedUpdate(
                     "WeblogEntryTagAggregateData.updateAddToTotalByName&WeblogNull");
             update.setParameter(1, new Long(amount));
             update.setParameter(2, weblogTagData.getName());
@@ -1433,7 +1433,7 @@
         }
         
         // delete all bad counts
-        Query removeq = strategy.getNamedQuery(
+        Query removeq = strategy.getNamedUpdate(
                 "WeblogEntryTagAggregateData.removeByTotalLessEqual");
         removeq.setParameter(1, new Integer(0));
         removeq.executeUpdate();
@@ -1545,7 +1545,7 @@
      * @inheritDoc
      */
     public void resetAllHitCounts() throws RollerException {       
-        Query q = strategy.getNamedQuery("HitCountData.updateDailyHitCountZero");
+        Query q = strategy.getNamedUpdate("HitCountData.updateDailyHitCountZero");
         q.executeUpdate();
     }
     

Modified: incubator/roller/branches/roller_4.0/tools/roller-core/roller-core.jar
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_4.0/tools/roller-core/roller-core.jar?view=diff&rev=511668&r1=511667&r2=511668
==============================================================================
Binary files - no diff available.



Mime
View raw message