jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xavier <xcou...@gmail.com>
Subject OCM issues with path and id fields (annotations)
Date Wed, 13 Feb 2008 17:26:40 GMT


I'm beginning working with the Jackrabbit OCM extension and i'm stuck with
the following issue on a very trivial example: in the 'Article' class, I
defined fields for the "content" of an article, plus fields for 'path' and
'uuid'. I set the mixins for referencing (hence, support for UUID). At the
save time, I was expecting that the uuid field would be populated by the
persistenceManager, but nope. (even if using ID is not a good practice, I
like to know that my config works)

Furthermore, when I save two distinct nodes with the same path (as annotated
with the 'path' attribute of the Field annotation), i don't see the path
indexing, as i could have when using the standard JCR API
(session.save(node), etc...)

My proto is based on spring 2.5 + springmodules 0.8 + Jackrabbit OCM 1.4,
and the 'glue' uses the patch submitted here :
http://jira.springframework.org/browse/MOD-446 The difference with the tests
in the patch is that I use annotations instead of xml mapping

I'm used to ORM frameworks like Hibernate, so I was expecting that the
persistenceManager would behave the same way, ie. setting values such as ID
or updating the path value if a node with the same path already exists. Is
it the way it works with OCM too ?

Here are the main pieces of code :

The domain object
public class Article {

	private String id = null;
	private String path = null;
	private String content = null;

        ... constructor, getters and setters

the service implementation
public class ArticleServiceImpl implements ArticleService {

	public void store(Article article) {

public class JcrMappingTemplate extends JcrTemplate implements
		JcrMappingOperations {
      public void insert(final java.lang.Object object) {
		execute(new JcrMappingCallback() {
			public Object doInJcrMapping(ObjectContentManager manager)
					throws JcrMappingException {
				return null;
		}, true);

        public Object execute(final JcrMappingCallback action,
			boolean exposeNativeSession) throws DataAccessException {
		return execute(new JcrCallback() {

			public Object doInJcr(Session session) throws RepositoryException {
				try {
					return action
				} catch (JcrMappingException e) {
					throw convertMappingAccessException(e);

		}, exposeNativeSession);

the test case
public class ArticleServiceTestCase {

	protected ArticleService articleService = null;
	public void testSaveAndRetrieveStringContent() {
		// store content
		Article original = new Article("/testSaveAndRetrieveStringContent", "a new
		Assert.assertNotNull("UUID not set for saved content", original.getId());

Thank you in advance
View this message in context: http://www.nabble.com/OCM-issues-with-path-and-id-fields-%28annotations%29-tp15460625p15460625.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

View raw message