You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/03/27 00:15:04 UTC
svn commit: r388976 -
/incubator/roller/trunk/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
Author: agilliland
Date: Sun Mar 26 14:15:01 2006
New Revision: 388976
URL: http://svn.apache.org/viewcvs?rev=388976&view=rev
Log:
changing getProperty() method to use PersistenceStrategy.load() instead of a Hibernate query. this is important because it allows us to use the Hibernate L2 cache, which we weren't using before.
Modified:
incubator/roller/trunk/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
Modified: incubator/roller/trunk/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java?rev=388976&r1=388975&r2=388976&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java Sun Mar 26 14:15:01 2006
@@ -21,6 +21,7 @@
import org.roller.business.PropertiesManagerImpl;
import org.roller.pojos.RollerPropertyData;
+
/**
* A hibernate specific implementation of the properties manager.
*
@@ -29,60 +30,58 @@
public class HibernatePropertiesManagerImpl extends PropertiesManagerImpl {
static final long serialVersionUID = -4326713177137796936L;
-
+
private static Log mLogger =
- LogFactory.getFactory().getInstance(HibernatePropertiesManagerImpl.class);
+ LogFactory.getLog(HibernatePropertiesManagerImpl.class);
- /** Creates a new instance of HibernatePropertiesManagerImpl */
+ /**
+ * Creates a new instance of HibernatePropertiesManagerImpl
+ */
public HibernatePropertiesManagerImpl(PersistenceStrategy strategy) {
super(strategy);
mLogger.debug("Instantiating Hibernate Properties Manager");
}
- /** Retrieve a single property by name */
+ /**
+ * Retrieve a single property by name
+ */
public RollerPropertyData getProperty(String name) throws RollerException {
- try
- {
+ try {
Session session = ((HibernateStrategy) mStrategy).getSession();
- Criteria criteria = session.createCriteria(RollerPropertyData.class);
- criteria.add(Expression.eq("name", name));
- criteria.setMaxResults(1);
- List list = criteria.list();
- return (list.size()!= 0) ? (RollerPropertyData)list.get(0) : null;
- }
- catch (HibernateException e)
- {
+ return (RollerPropertyData) mStrategy.load(name, RollerPropertyData.class);
+ } catch (HibernateException e) {
throw new RollerException(e);
}
}
- /** Retrieve all properties */
+ /**
+ * Retrieve all properties
+ */
public Map getProperties() throws RollerException {
HashMap props = new HashMap();
- try
- {
+ try {
Session session = ((HibernateStrategy) mStrategy).getSession();
Criteria criteria = session.createCriteria(RollerPropertyData.class);
List list = criteria.list();
- // for convenience sake we are going to put the list of props
- // into a map for users to access it. The value element of the
- // hash still needs to be the RollerPropertyData object so that
- // we can save the elements again after they have been updated
+ /*
+ * for convenience sake we are going to put the list of props
+ * into a map for users to access it. The value element of the
+ * hash still needs to be the RollerPropertyData object so that
+ * we can save the elements again after they have been updated
+ */
RollerPropertyData prop = null;
Iterator it = list.iterator();
while(it.hasNext()) {
prop = (RollerPropertyData) it.next();
props.put(prop.getName(), prop);
}
- }
- catch (HibernateException e)
- {
+ } catch (HibernateException e) {
throw new RollerException(e);
}