Hello,

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
@Node(jcrMixinTypes="mix:referenceable,mix:lockable,mix:versionable")
public class Article {

        @Field(uuid=true)
        private String id = null;
        
        @Field(path=true)
        private String path = null;
        
        @Field
        private String content = null;

        ... constructor, getters and setters
}

the service implementation
public class ArticleServiceImpl implements ArticleService {

        ...
        @Override
        public void store(Article article) {
                jcrMappingTemplate.insert(article);
                jcrMappingTemplate.save();
        }
        ...
}

JCRMappingTemplate
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 {
                                manager.insert(object);
                                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
                                                        
.doInJcrMapping(createPersistenceManager(session));
                                } catch (JcrMappingException e) {
                                        throw convertMappingAccessException(e);
                                }
                        }

                }, exposeNativeSession);
        }
}

the test case
public class ArticleServiceTestCase {

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




Thank you in advance
Xavier
-- 
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.

Reply via email to