jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AdamR <adam.r...@runbox.com>
Subject Re: spring-modules-jcr problem
Date Thu, 19 Jun 2008 09:07:29 GMT

I fixed the problem shortly after posting this message... isn't that always
the way?!

As I wanted to use DAOs (inherited from JcrDaoSupport) rather than the
springmodules templates for my repository access code, I hadn't bothered
injecting the template into my DAO. But the getSession() method needs the
template in order to get it's allowCreate property, which determines whether
the session can be used outside of a transaction. That is my crude
understanding at least. 

The following works without using transactions:

  	<bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
    	<property name="sessionFactory" ref="jcrSessionFactory"/>
    	<property name="allowCreate" value="true"/>
	</bean>

	<!-- DAO configurations -->
	<bean id="repositoryEntityDao" 
         
class="com.priocept.tui.demo.dao.jackrabbit.JackrabbitRepositoryEntityDaoImpl">
		<property name="sessionFactory" ref="jcrSessionFactory"/>
		<property name="template" ref="jcrTemplate"/>
	</bean>

With the DAO calling gestSession(true) as follows:

public class JackrabbitRepositoryEntityDaoImpl 
	extends JcrDaoSupport implements RepositoryEntityDao {

	public void create(RepositoryEntity entity) {

		Session session = getSession(true);
		try {
			Node root = session.getRootNode();
			root.addNode(entity.getPath());
                        .....

			session.save();
		}
		.....
	}
        ....
}
-- 
View this message in context: http://www.nabble.com/spring-modules-jcr-problem-tp17986274p18000587.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message