//# 12 errors, 363 messages
//#
/*
    //#JPAPersistenceStrategy.java:1:1: class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1
    //#JPAPersistenceStrategy.java:1:1: method: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1__static_init
    //#JPAPersistenceStrategy.java:1:1: class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.business.jpa;

import java.util.Collection;
import java.util.Iterator;
import java.util.Enumeration;
import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.config.WebloggerConfig;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityManager;
import javax.persistence.FlushModeType;
import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.roller.weblogger.business.DatabaseProvider;


/**
 * Responsible for the lowest-level interaction with the JPA API.
 */
@com.google.inject.Singleton
public class JPAPersistenceStrategy {
    
    private static Log logger = 
    //#JPAPersistenceStrategy.java:51: method: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init
    //#JPAPersistenceStrategy.java:51: Warning: method not available
    //#    -- call on LogFactory org.apache.commons.logging.LogFactory:getFactory()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init
    //#    unanalyzed callee: LogFactory org.apache.commons.logging.LogFactory:getFactory()
    //#JPAPersistenceStrategy.java:51: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getInstance(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getInstance(Class)
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy]
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.flush()V
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getDynamicQuery(Ljava/lang/String;)Ljavax/persistence/Query;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getEntityManager(Z)Ljavax/persistence/EntityManager;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getNamedQuery(Ljava/lang/String;)Ljavax/persistence/Query;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getNamedUpdate(Ljava/lang/String;)Ljavax/persistence/Query;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getThreadLocalEntityManager()Ljavax/persistence/EntityManager;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.isTransactionActive(Ljavax/persistence/EntityManager;)Z
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.load(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.release()V
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.remove(Ljava/lang/Class;Ljava/lang/String;)V
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.remove(Ljava/lang/Object;)V
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.removeAll(Ljava/util/Collection;)V
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.setThreadLocalEntityManager(Ljava/lang/Object;)V
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.store(Ljava/lang/Object;)Ljava/lang/Object;
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): logger
    //#presumption(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): org.apache.commons.logging.LogFactory:getFactory(...)@51 != null
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.flush()V == &flush
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getDynamicQuery(Ljava/lang/String;)Ljavax/persistence/Query; == &getDynamicQuery
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getEntityManager(Z)Ljavax/persistence/EntityManager; == &getEntityManager
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getNamedQuery(Ljava/lang/String;)Ljavax/persistence/Query; == &getNamedQuery
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getNamedUpdate(Ljava/lang/String;)Ljavax/persistence/Query; == &getNamedUpdate
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.getThreadLocalEntityManager()Ljavax/persistence/EntityManager; == &getThreadLocalEntityManager
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.isTransactionActive(Ljavax/persistence/EntityManager;)Z == &isTransactionActive
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.load(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object; == &load
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.release()V == &release
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.remove(Ljava/lang/Class;Ljava/lang/String;)V == &remove
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.remove(Ljava/lang/Object;)V == &remove
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.removeAll(Ljava/util/Collection;)V == &removeAll
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.setThreadLocalEntityManager(Ljava/lang/Object;)V == &setThreadLocalEntityManager
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): __Dispatch_Table.store(Ljava/lang/Object;)Ljava/lang/Object; == &store
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init): init'ed(logger)
    //#JPAPersistenceStrategy.java:51: end of method: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy__static_init
        LogFactory.getFactory().getInstance(JPAPersistenceStrategy.class);
    
    /**
     * The thread local EntityManager.
     */
    private final ThreadLocal threadLocalEntityManager = new ThreadLocal();
    
    /**
     * The EntityManagerFactory for this Roller instance.
     */
    private EntityManagerFactory emf = null;
    
            
    /**
     * Construct by finding JPA EntityManagerFactory.
     * @param dbProvider database configuration information for manual configuration.
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    @com.google.inject.Inject
    protected JPAPersistenceStrategy(DatabaseProvider dbProvider) throws WebloggerException {
    //#JPAPersistenceStrategy.java:71: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): ": "._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "="._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "Could not load properties from "._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "Could not locate properties to load "._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "Could not look up EntityManagerFactory in jndi at "._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "Fetching property ["._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "JPAEMF.properties"._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "]"._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "java:comp.env."._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "jpa.configurationType"._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): "jpa.emf.jndi.name"._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.__Tag
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.jdbcConnectionURL
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.jdbcDriverClass
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.jdbcPassword
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.jdbcUsername
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.jndiName
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.jndiName._tainted
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): dbProvider.type
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): logger
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider$ConfigurationType.JNDI_NAME
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Descendant_Table[org/apache/roller/weblogger/business/DatabaseProvider]
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Descendant_Table[others]
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Dispatch_Table.getJdbcConnectionURL()Ljava/lang/String;
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Dispatch_Table.getJdbcDriverClass()Ljava/lang/String;
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Dispatch_Table.getJdbcPassword()Ljava/lang/String;
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Dispatch_Table.getJdbcUsername()Ljava/lang/String;
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Dispatch_Table.getJndiName()Ljava/lang/String;
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/business/DatabaseProvider.__Dispatch_Table.getType()Lorg/apache/roller/weblogger/business/DatabaseProvider$ConfigurationType;
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/config/WebloggerConfig.config
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/config/WebloggerConfig.log
    //#input(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): this
    //#output(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): new ThreadLocal(JPAPersistenceStrategy#1) num objects
    //#output(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): this.emf
    //#output(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): this.threadLocalEntityManager
    //#new obj(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): new ThreadLocal(JPAPersistenceStrategy#1)
    //#pre[11] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/config/WebloggerConfig.config != null
    //#pre[12] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): org/apache/roller/weblogger/config/WebloggerConfig.log != null
    //#pre[1] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) dbProvider != null
    //#pre[2] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) dbProvider.__Tag == org/apache/roller/weblogger/business/DatabaseProvider
    //#pre[3] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) init'ed(dbProvider.jdbcConnectionURL)
    //#pre[4] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) init'ed(dbProvider.jdbcDriverClass)
    //#pre[5] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) init'ed(dbProvider.jdbcPassword)
    //#pre[6] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) init'ed(dbProvider.jdbcUsername)
    //#pre[7] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) init'ed(dbProvider.jndiName)
    //#pre[9] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) init'ed(dbProvider.type)
    //#pre[10] (void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): (soft) logger != null
    //#presumption(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.security.AccessController:doPrivileged(...)@343 != null
    //#presumption(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.util.Enumeration:nextElement(...)@89 != null
    //#presumption(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.util.Properties:keys(...)@205 != null
    //#post(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): init'ed(this.emf)
    //#post(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): this.threadLocalEntityManager == &new ThreadLocal(JPAPersistenceStrategy#1)
    //#post(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): new ThreadLocal(JPAPersistenceStrategy#1) num objects == 1
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.security.AccessController:doPrivileged
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.util.Properties
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.lang.ClassLoader:getResourceAsStream
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:org.apache.roller.RollerException
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.util.Properties:load
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.io.InputStream:close
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.lang.String:trim
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.util.Properties:getProperty
    //#unanalyzed(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): Effects-of-calling:java.util.Properties:keys
    //#test_vector(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.lang.String:equals(...)@73: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.lang.String:startsWith(...)@90: {1}, {0}
    //#test_vector(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.lang.String:startsWith(...)@90: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)): java.util.Enumeration:hasMoreElements(...)@88: {0}, {1}
        String jpaConfigurationType = WebloggerConfig.getProperty("jpa.configurationType");
        if ("jndi".equals(jpaConfigurationType)) {
            String emfJndiName = "java:comp/env/" + WebloggerConfig.getProperty("jpa.emf.jndi.name");
            try {
                emf = (EntityManagerFactory) new InitialContext().lookup(emfJndiName);
            } catch (NamingException e) {
                throw new WebloggerException("Could not look up EntityManagerFactory in jndi at " + emfJndiName, e);
            }
        } else {

            // Pull in any properties defined in JMAEMF.properties config file
            Properties emfProps = loadPropertiesFromResourceName(
                    "JPAEMF.properties", getContextClassLoader());

            // Add all OpenJPA and Toplinks properties found in WebloggerConfig
            Enumeration keys = WebloggerConfig.keys();
            while (keys.hasMoreElements()) {
                String key = (String) keys.nextElement();
                if (key.startsWith("openjpa.") || key.startsWith("toplink.")) {
                    String value = WebloggerConfig.getProperty(key);
                    logger.info(key + ": " + value);
    //#JPAPersistenceStrategy.java:92: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
                    emfProps.setProperty(key, value);
                }
            }

            if (dbProvider.getType() == DatabaseProvider.ConfigurationType.JNDI_NAME) {
                // We're doing JNDI, so set OpenJPA JNDI name property
                String jndiName = "java:comp/env/" + dbProvider.getJndiName();
                emfProps.setProperty("openjpa.ConnectionFactoryName", jndiName);

            } else {
                // So set JDBD properties for OpenJPA
                emfProps.setProperty("openjpa.ConnectionDriverName", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("openjpa.ConnectionURL", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("openjpa.ConnectionUserName", dbProvider.getJdbcUsername());
                emfProps.setProperty("openjpa.ConnectionPassword", dbProvider.getJdbcPassword());

                // And Toplink JPA
                emfProps.setProperty("toplink.jdbc.driver", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("toplink.jdbc.url", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("toplink.jdbc.user", dbProvider.getJdbcUsername());
                emfProps.setProperty("toplink.jdbc.password", dbProvider.getJdbcPassword());

                // And Hibernate JPA
                emfProps.setProperty("hibernate.connection.driver_class", dbProvider.getJdbcDriverClass());
                emfProps.setProperty("hibernate.connection.url", dbProvider.getJdbcConnectionURL());
                emfProps.setProperty("hibernate.connection.username", dbProvider.getJdbcUsername());
                emfProps.setProperty("hibernate.connection.password", dbProvider.getJdbcPassword());
            }

            try {
                this.emf = Persistence.createEntityManagerFactory("RollerPU", emfProps);
            } catch (PersistenceException pe) {
                logger.error("ERROR: creating entity manager", pe);
                throw new WebloggerException(pe);
            }
        }
    }
    //#JPAPersistenceStrategy.java:129: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy(DatabaseProvider)
                        
    /**
     * Flush changes to the datastore, commit transaction, release em.
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public void flush() throws WebloggerException {
        try {
            EntityManager em = getEntityManager(true);
    //#JPAPersistenceStrategy.java:137: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.flush()
    //#input(void flush()): this
    //#input(void flush()): this.emf
    //#input(void flush()): this.threadLocalEntityManager
    //#pre[3] (void flush()): this.threadLocalEntityManager != null
    //#pre[2] (void flush()): (soft) this.emf != null
    //#presumption(void flush()): javax.persistence.EntityManager:getTransaction(...)@138 != null
    //#unanalyzed(void flush()): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void flush()): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void flush()): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void flush()): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void flush()): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void flush()): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#unanalyzed(void flush()): Effects-of-calling:org.apache.roller.RollerException
            em.getTransaction().commit();
    //#JPAPersistenceStrategy.java:138: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void flush()
    //#    basic block: bb_2
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        } catch (PersistenceException pe) {
            throw new WebloggerException(pe);
        }
    }
    //#JPAPersistenceStrategy.java:142: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.flush()
    
    /**
     * Release database session, rolls back any uncommitted changes.
     */
    public void release() {
        EntityManager em = getEntityManager(false);
    //#JPAPersistenceStrategy.java:148: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.release()
    //#input(void release()): this
    //#input(void release()): this.emf
    //#input(void release()): this.threadLocalEntityManager
    //#pre[3] (void release()): this.threadLocalEntityManager != null
    //#pre[2] (void release()): (soft) this.emf != null
    //#presumption(void release()): javax.persistence.EntityManager:getTransaction(...)@150 != null
    //#unanalyzed(void release()): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void release()): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void release()): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void release()): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void release()): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void release()): Effects-of-calling:javax.persistence.EntityTransaction:begin
        if (isTransactionActive(em)) {
            em.getTransaction().rollback();
    //#JPAPersistenceStrategy.java:150: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void release()
    //#    basic block: bb_2
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        }
        em.close();
    //#JPAPersistenceStrategy.java:152: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void release()
    //#    basic block: bb_3
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        setThreadLocalEntityManager(null);
    }
    //#JPAPersistenceStrategy.java:154: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.release()
    
    /**
     * Store object using an existing transaction.
     * @param obj the object to persist
     * @return the object persisted
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public Object store(Object obj) throws WebloggerException {
        EntityManager em = getEntityManager(true);
    //#JPAPersistenceStrategy.java:163: method: Object org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.store(Object)
    //#input(Object store(Object)): obj
    //#input(Object store(Object)): this
    //#input(Object store(Object)): this.emf
    //#input(Object store(Object)): this.threadLocalEntityManager
    //#output(Object store(Object)): return_value
    //#pre[4] (Object store(Object)): this.threadLocalEntityManager != null
    //#pre[3] (Object store(Object)): (soft) this.emf != null
    //#post(Object store(Object)): return_value == obj
    //#post(Object store(Object)): init'ed(return_value)
    //#unanalyzed(Object store(Object)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(Object store(Object)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(Object store(Object)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(Object store(Object)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(Object store(Object)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(Object store(Object)): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#test_vector(Object store(Object)): javax.persistence.EntityManager:contains(...)@164: {1}, {0}
        if (!em.contains(obj)) {
    //#JPAPersistenceStrategy.java:164: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: Object store(Object)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
            // If entity is not managed we can assume it is new
            em.persist(obj);
        }
        return obj;
    //#JPAPersistenceStrategy.java:168: end of method: Object org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.store(Object)
    }
    
    /**
     * Remove object from persistence storage.
     * @param clazz the class of object to remove
     * @param id the id of the object to remove
     * @throws WebloggerException on any error deleting object
     */
    public void remove(Class clazz, String id) throws WebloggerException {
        EntityManager em = getEntityManager(true);
    //#JPAPersistenceStrategy.java:178: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.remove(Class, String)
    //#input(void remove(Class, String)): clazz
    //#input(void remove(Class, String)): id
    //#input(void remove(Class, String)): this
    //#input(void remove(Class, String)): this.emf
    //#input(void remove(Class, String)): this.threadLocalEntityManager
    //#pre[5] (void remove(Class, String)): this.threadLocalEntityManager != null
    //#pre[4] (void remove(Class, String)): (soft) this.emf != null
    //#unanalyzed(void remove(Class, String)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void remove(Class, String)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void remove(Class, String)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void remove(Class, String)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void remove(Class, String)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void remove(Class, String)): Effects-of-calling:javax.persistence.EntityTransaction:begin
        Object po = em.find(clazz, id);
    //#JPAPersistenceStrategy.java:179: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void remove(Class, String)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        em.remove(po);
    }
    //#JPAPersistenceStrategy.java:181: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.remove(Class, String)
    
    /**
     * Remove object from persistence storage.
     * @param po the persistent object to remove
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public void remove(Object po) throws WebloggerException {
        EntityManager em = getEntityManager(true);
    //#JPAPersistenceStrategy.java:189: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.remove(Object)
    //#input(void remove(Object)): po
    //#input(void remove(Object)): this
    //#input(void remove(Object)): this.emf
    //#input(void remove(Object)): this.threadLocalEntityManager
    //#pre[4] (void remove(Object)): this.threadLocalEntityManager != null
    //#pre[3] (void remove(Object)): (soft) this.emf != null
    //#unanalyzed(void remove(Object)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void remove(Object)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void remove(Object)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void remove(Object)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void remove(Object)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void remove(Object)): Effects-of-calling:javax.persistence.EntityTransaction:begin
        em.remove(po);
    //#JPAPersistenceStrategy.java:190: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void remove(Object)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
    }
    //#JPAPersistenceStrategy.java:191: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.remove(Object)
    
    /**
     * Remove object from persistence storage.
     * @param pos the persistent objects to remove
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public void removeAll(Collection pos) throws WebloggerException {
        EntityManager em = getEntityManager(true);
    //#JPAPersistenceStrategy.java:199: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.removeAll(Collection)
    //#input(void removeAll(Collection)): pos
    //#input(void removeAll(Collection)): this
    //#input(void removeAll(Collection)): this.emf
    //#input(void removeAll(Collection)): this.threadLocalEntityManager
    //#pre[1] (void removeAll(Collection)): pos != null
    //#pre[4] (void removeAll(Collection)): this.threadLocalEntityManager != null
    //#pre[3] (void removeAll(Collection)): (soft) this.emf != null
    //#unanalyzed(void removeAll(Collection)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void removeAll(Collection)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void removeAll(Collection)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void removeAll(Collection)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void removeAll(Collection)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void removeAll(Collection)): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#test_vector(void removeAll(Collection)): java.util.Iterator:hasNext(...)@200: {0}, {1}
        for (Iterator iterator = pos.iterator(); iterator.hasNext();) {
            Object obj = iterator.next();
            em.remove(obj);
    //#JPAPersistenceStrategy.java:202: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: void removeAll(Collection)
    //#    basic block: bb_3
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        }
    }    
    //#JPAPersistenceStrategy.java:204: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.removeAll(Collection)
    
    /**
     * Retrieve object, no transaction needed.
     * @param clazz the class of object to retrieve
     * @param id the id of the object to retrieve
     * @return the object retrieved
     * @throws WebloggerException on any error retrieving object
     */
    public Object load(Class clazz, String id)
    throws WebloggerException {
        EntityManager em = getEntityManager(false);
    //#JPAPersistenceStrategy.java:215: method: Object org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.load(Class, String)
    //#input(Object load(Class, String)): clazz
    //#input(Object load(Class, String)): id
    //#input(Object load(Class, String)): this
    //#input(Object load(Class, String)): this.emf
    //#input(Object load(Class, String)): this.threadLocalEntityManager
    //#output(Object load(Class, String)): return_value
    //#pre[5] (Object load(Class, String)): this.threadLocalEntityManager != null
    //#pre[4] (Object load(Class, String)): (soft) this.emf != null
    //#post(Object load(Class, String)): init'ed(return_value)
    //#unanalyzed(Object load(Class, String)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(Object load(Class, String)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(Object load(Class, String)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(Object load(Class, String)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(Object load(Class, String)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(Object load(Class, String)): Effects-of-calling:javax.persistence.EntityTransaction:begin
        return em.find(clazz, id);
    //#JPAPersistenceStrategy.java:216: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: Object load(Class, String)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
    //#JPAPersistenceStrategy.java:216: end of method: Object org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.load(Class, String)
    }
    
    /**
     * Return true if a transaction is active on the current EntityManager.
     * @param em the persistence manager
     * @return true if the persistence manager is not null and has an active
     *         transaction
     */
    private boolean isTransactionActive(EntityManager em) {
        if (em == null) {
    //#JPAPersistenceStrategy.java:226: method: bool org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.isTransactionActive(EntityManager)
    //#input(bool isTransactionActive(EntityManager)): em
    //#output(bool isTransactionActive(EntityManager)): return_value
    //#presumption(bool isTransactionActive(EntityManager)): javax.persistence.EntityManager:getTransaction(...)@229 != null
    //#post(bool isTransactionActive(EntityManager)): init'ed(return_value)
    //#test_vector(bool isTransactionActive(EntityManager)): em: Inverse{null}, Addr_Set{null}
            return false;
        }
        return em.getTransaction().isActive();
    //#JPAPersistenceStrategy.java:229: end of method: bool org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.isTransactionActive(EntityManager)
    }
    
    /**
     * Get the EntityManager associated with the current thread of control.
     * @param isTransactionRequired true if a transaction is begun if not
     * already active
     * @return the EntityManager
     */
    private EntityManager getEntityManager(boolean isTransactionRequired) {
        EntityManager em = getThreadLocalEntityManager();
    //#JPAPersistenceStrategy.java:239: method: EntityManager org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getEntityManager(bool)
    //#input(EntityManager getEntityManager(bool)): isTransactionRequired
    //#input(EntityManager getEntityManager(bool)): this
    //#input(EntityManager getEntityManager(bool)): this.emf
    //#input(EntityManager getEntityManager(bool)): this.threadLocalEntityManager
    //#output(EntityManager getEntityManager(bool)): return_value
    //#pre[4] (EntityManager getEntityManager(bool)): this.threadLocalEntityManager != null
    //#pre[3] (EntityManager getEntityManager(bool)): (soft) this.emf != null
    //#presumption(EntityManager getEntityManager(bool)): javax.persistence.EntityManager:getTransaction(...)@240 != null
    //#presumption(EntityManager getEntityManager(bool)): javax.persistence.EntityManager:getTransaction(...)@241 != null
    //#post(EntityManager getEntityManager(bool)): init'ed(return_value)
    //#unanalyzed(EntityManager getEntityManager(bool)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(EntityManager getEntityManager(bool)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(EntityManager getEntityManager(bool)): Effects-of-calling:java.lang.ThreadLocal:set
    //#test_vector(EntityManager getEntityManager(bool)): isTransactionRequired: {0}, {1}
    //#test_vector(EntityManager getEntityManager(bool)): javax.persistence.EntityTransaction:isActive(...)@240: {1}, {0}
        if (isTransactionRequired && !em.getTransaction().isActive()) {
    //#JPAPersistenceStrategy.java:240: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: EntityManager getEntityManager(bool)
    //#    basic block: bb_2
    //#    assertion: em != null
    //#    VN: getThreadLocalEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
            em.getTransaction().begin();
        }
        return em;
    //#JPAPersistenceStrategy.java:243: end of method: EntityManager org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getEntityManager(bool)
    }
    
    /**
     * Get the current ThreadLocal EntityManager
     */
    private EntityManager getThreadLocalEntityManager() {
        EntityManager em = (EntityManager) threadLocalEntityManager.get();
    //#JPAPersistenceStrategy.java:250: method: EntityManager org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getThreadLocalEntityManager()
    //#input(EntityManager getThreadLocalEntityManager()): this
    //#input(EntityManager getThreadLocalEntityManager()): this.emf
    //#input(EntityManager getThreadLocalEntityManager()): this.threadLocalEntityManager
    //#output(EntityManager getThreadLocalEntityManager()): return_value
    //#pre[3] (EntityManager getThreadLocalEntityManager()): this.threadLocalEntityManager != null
    //#pre[2] (EntityManager getThreadLocalEntityManager()): (soft) this.emf != null
    //#post(EntityManager getThreadLocalEntityManager()): init'ed(return_value)
    //#test_vector(EntityManager getThreadLocalEntityManager()): java.lang.ThreadLocal:get(...)@250: Inverse{null}, Addr_Set{null}
        if (em == null) {
            em = emf.createEntityManager();
            threadLocalEntityManager.set(em);
        }
        return em;
    //#JPAPersistenceStrategy.java:255: end of method: EntityManager org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getThreadLocalEntityManager()
    }
    
    /**
     * Set the current ThreadLocal EntityManager
     */
    private void setThreadLocalEntityManager(Object em) {
        threadLocalEntityManager.set(em);
    //#JPAPersistenceStrategy.java:262: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.setThreadLocalEntityManager(Object)
    //#input(void setThreadLocalEntityManager(Object)): em
    //#input(void setThreadLocalEntityManager(Object)): this
    //#input(void setThreadLocalEntityManager(Object)): this.threadLocalEntityManager
    //#pre[3] (void setThreadLocalEntityManager(Object)): this.threadLocalEntityManager != null
    }
    //#JPAPersistenceStrategy.java:263: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.setThreadLocalEntityManager(Object)
    
    /**
     * Get named query with FlushModeType.COMMIT
     * @param queryName the name of the query
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public Query getNamedQuery(String queryName)
    throws WebloggerException {
        EntityManager em = getEntityManager(false);
    //#JPAPersistenceStrategy.java:272: method: Query org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getNamedQuery(String)
    //#input(Query getNamedQuery(String)): javax.persistence.FlushModeType.COMMIT
    //#input(Query getNamedQuery(String)): queryName
    //#input(Query getNamedQuery(String)): this
    //#input(Query getNamedQuery(String)): this.emf
    //#input(Query getNamedQuery(String)): this.threadLocalEntityManager
    //#output(Query getNamedQuery(String)): return_value
    //#pre[4] (Query getNamedQuery(String)): this.threadLocalEntityManager != null
    //#pre[3] (Query getNamedQuery(String)): (soft) this.emf != null
    //#presumption(Query getNamedQuery(String)): javax.persistence.EntityManager:createNamedQuery(...)@273 != null
    //#presumption(Query getNamedQuery(String)): init'ed(javax.persistence.FlushModeType.COMMIT)
    //#post(Query getNamedQuery(String)): (soft) return_value != null
    //#unanalyzed(Query getNamedQuery(String)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(Query getNamedQuery(String)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(Query getNamedQuery(String)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(Query getNamedQuery(String)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(Query getNamedQuery(String)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(Query getNamedQuery(String)): Effects-of-calling:javax.persistence.EntityTransaction:begin
        Query q = em.createNamedQuery(queryName);
    //#JPAPersistenceStrategy.java:273: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: Query getNamedQuery(String)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        // Never flush for queries. Roller code assumes this behavior
        q.setFlushMode(FlushModeType.COMMIT);
        return q;
    //#JPAPersistenceStrategy.java:276: end of method: Query org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getNamedQuery(String)
    }
    
    /**
     * Create query from queryString with FlushModeType.COMMIT
     * @param queryString the quuery
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public Query getDynamicQuery(String queryString)
    throws WebloggerException {
        EntityManager em = getEntityManager(false);
    //#JPAPersistenceStrategy.java:286: method: Query org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getDynamicQuery(String)
    //#input(Query getDynamicQuery(String)): javax.persistence.FlushModeType.COMMIT
    //#input(Query getDynamicQuery(String)): queryString
    //#input(Query getDynamicQuery(String)): this
    //#input(Query getDynamicQuery(String)): this.emf
    //#input(Query getDynamicQuery(String)): this.threadLocalEntityManager
    //#output(Query getDynamicQuery(String)): return_value
    //#pre[4] (Query getDynamicQuery(String)): this.threadLocalEntityManager != null
    //#pre[3] (Query getDynamicQuery(String)): (soft) this.emf != null
    //#presumption(Query getDynamicQuery(String)): javax.persistence.EntityManager:createQuery(...)@287 != null
    //#presumption(Query getDynamicQuery(String)): init'ed(javax.persistence.FlushModeType.COMMIT)
    //#post(Query getDynamicQuery(String)): (soft) return_value != null
    //#unanalyzed(Query getDynamicQuery(String)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(Query getDynamicQuery(String)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(Query getDynamicQuery(String)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(Query getDynamicQuery(String)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(Query getDynamicQuery(String)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(Query getDynamicQuery(String)): Effects-of-calling:javax.persistence.EntityTransaction:begin
        Query q = em.createQuery(queryString);
    //#JPAPersistenceStrategy.java:287: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: Query getDynamicQuery(String)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        // Never flush for queries. Roller code assumes this behavior
        q.setFlushMode(FlushModeType.COMMIT);
        return q;
    //#JPAPersistenceStrategy.java:290: end of method: Query org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getDynamicQuery(String)
    }
    
    /**
     * Get named update query with default flush mode
     * @param queryName the name of the query
     * @throws org.apache.roller.weblogger.WebloggerException on any error
     */
    public Query getNamedUpdate(String queryName)
    throws WebloggerException {
        EntityManager em = getEntityManager(true);
    //#JPAPersistenceStrategy.java:300: method: Query org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getNamedUpdate(String)
    //#input(Query getNamedUpdate(String)): queryName
    //#input(Query getNamedUpdate(String)): this
    //#input(Query getNamedUpdate(String)): this.emf
    //#input(Query getNamedUpdate(String)): this.threadLocalEntityManager
    //#output(Query getNamedUpdate(String)): return_value
    //#pre[4] (Query getNamedUpdate(String)): this.threadLocalEntityManager != null
    //#pre[3] (Query getNamedUpdate(String)): (soft) this.emf != null
    //#post(Query getNamedUpdate(String)): init'ed(return_value)
    //#unanalyzed(Query getNamedUpdate(String)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(Query getNamedUpdate(String)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(Query getNamedUpdate(String)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(Query getNamedUpdate(String)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(Query getNamedUpdate(String)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(Query getNamedUpdate(String)): Effects-of-calling:javax.persistence.EntityTransaction:begin
        Query q = em.createNamedQuery(queryName);
    //#JPAPersistenceStrategy.java:301: ?null dereference
    //#    em != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
    //#    method: Query getNamedUpdate(String)
    //#    basic block: Entry_BB_1
    //#    assertion: em != null
    //#    VN: getEntityManager(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
        return q;
    //#JPAPersistenceStrategy.java:302: end of method: Query org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getNamedUpdate(String)
    }
    
    /**
     * Loads properties from given resourceName using given class loader
     * @param resourceName The name of the resource containing properties
     * @param cl Classloeder to be used to locate the resouce
     * @return A properties object
     * @throws WebloggerException
     */
    private static Properties loadPropertiesFromResourceName(
            String resourceName, ClassLoader cl) throws WebloggerException {
        Properties props = new Properties();
    //#JPAPersistenceStrategy.java:314: method: Properties org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.loadPropertiesFromResourceName(String, ClassLoader)
    //#input(Properties loadPropertiesFromResourceName(String, ClassLoader)): "Could not load properties from "._tainted
    //#input(Properties loadPropertiesFromResourceName(String, ClassLoader)): "Could not locate properties to load "._tainted
    //#input(Properties loadPropertiesFromResourceName(String, ClassLoader)): cl
    //#input(Properties loadPropertiesFromResourceName(String, ClassLoader)): resourceName
    //#input(Properties loadPropertiesFromResourceName(String, ClassLoader)): resourceName._tainted
    //#output(Properties loadPropertiesFromResourceName(String, ClassLoader)): new Properties(loadPropertiesFromResourceName#1) num objects
    //#output(Properties loadPropertiesFromResourceName(String, ClassLoader)): return_value
    //#new obj(Properties loadPropertiesFromResourceName(String, ClassLoader)): new Properties(loadPropertiesFromResourceName#1)
    //#pre[1] (Properties loadPropertiesFromResourceName(String, ClassLoader)): cl != null
    //#presumption(Properties loadPropertiesFromResourceName(String, ClassLoader)): java.lang.ClassLoader:getResourceAsStream(...)@316 != null
    //#post(Properties loadPropertiesFromResourceName(String, ClassLoader)): return_value == &new Properties(loadPropertiesFromResourceName#1)
    //#post(Properties loadPropertiesFromResourceName(String, ClassLoader)): new Properties(loadPropertiesFromResourceName#1) num objects == 1
    //#unanalyzed(Properties loadPropertiesFromResourceName(String, ClassLoader)): Effects-of-calling:org.apache.roller.RollerException
        InputStream in;
        in = cl.getResourceAsStream(resourceName);
        if (in == null) {
            //TODO: Check how i18n is done in roller
            throw new WebloggerException(
                    "Could not locate properties to load " + resourceName);
        }
        try {
            props.load(in);
        } catch (IOException ioe) {
            throw new WebloggerException(
                    "Could not load properties from " + resourceName);
        } finally {
            try {
                in.close();
            } catch (IOException ioe) {
            }
        }
        
        return props;
    //#JPAPersistenceStrategy.java:334: end of method: Properties org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.loadPropertiesFromResourceName(String, ClassLoader)
    }
    
    /**
     * Get the context class loader associated with the current thread. This is
     * done in a doPrivileged block because it is a secure method.
     * @return the current thread's context class loader.
     */
    private static ClassLoader getContextClassLoader() {
        return (ClassLoader) AccessController.doPrivileged(
    //#JPAPersistenceStrategy.java:343: method: ClassLoader org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getContextClassLoader()
    //#output(ClassLoader getContextClassLoader()): return_value
    //#post(ClassLoader getContextClassLoader()): init'ed(return_value)
    //#JPAPersistenceStrategy.java:343: end of method: ClassLoader org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.getContextClassLoader()
                new PrivilegedAction() {
    //#JPAPersistenceStrategy.java:344: method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1()
    //#JPAPersistenceStrategy.java:344: end of method: void org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1()
            public Object run() {
                return Thread.currentThread().getContextClassLoader();
    //#JPAPersistenceStrategy.java:346: method: Object org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1.run()
    //#output(Object run()): return_value
    //#presumption(Object run()): java.lang.Thread:currentThread(...)@346 != null
    //#post(Object run()): init'ed(return_value)
    //#JPAPersistenceStrategy.java:346: end of method: Object org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1.run()
            }
        });
    }  
}
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1__static_init): __Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy$1]
    //#output(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1__static_init): __Dispatch_Table.run()Ljava/lang/Object;
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1__static_init): __Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy$1] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1__static_init): __Dispatch_Table.run()Ljava/lang/Object; == &run
    //#JPAPersistenceStrategy.java:: end of method: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1.org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1__static_init
    //#JPAPersistenceStrategy.java:: end of class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy$1
    //#JPAPersistenceStrategy.java:: end of class: org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy
