About update method in AbstractJcrDAO.java

15 views
Skip to first unread message

Maurice

unread,
Jan 9, 2009, 12:55:56 AM1/9/09
to jc...@googlegroups.com
Hello there,

I am trying to make versionable node for my class(Named MyTest.java). MyTest node has a parent node called Test. The Test node is not versionable but MyTest node is versionable.
I created Test node as parent node and under it  created MyTest node and persisted all anottated fields in MyTest.java class in MyTest node. I did it by calling create( T entity ) method of AbstractJcrDAO.java class.
By calling update( T entity ) method of AbstractJcrDAO.java class I tryed to update MyTest node in repository. I got the below error


org.jcrom.JcrMappingException: Could not update node
    at org.jcrom.dao.AbstractJcrDAO.update(AbstractJcrDAO.java:207)
    at org.jcrom.dao.AbstractJcrDAO.update(AbstractJcrDAO.java:178)
    at org.jcrom.dao.AbstractJcrDAO.update(AbstractJcrDAO.java:168)
    at roolo.elo.RepositoryJcrImpl.updateELO(RepositoryJcrImpl.java:288)
    at roolo.elo.test.JUnit.TestELOAdd.update_one_string_nolocale_elo(TestAdd.java:629)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
    at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
    at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: javax.jcr.UnsupportedRepositoryOperationException: Unable to perform versioning operation on non versionable node: /Test
    at org.apache.jackrabbit.core.NodeImpl.checkVersionable(NodeImpl.java:3220)

According the error I found that Jcrom had tried to update the parent node I mean the Test node. I got error because the Test node is not versionable.

I changed node = getSession().getRootNode().getNode(relativePath(jcrom.getPath(entity)));  statment in update( T entity, String childNodeFilter, int maxDepth ) method of AbstractJcrDAO.java class  to node = getSession().getRootNode().getNode(Test/MyTest)
and it worked errorless.
I looked at the repository by JCR Browser and observed that the other version of MyTest node has been created but its data are the same as first version data (version 1.0). I repeated  the update procedure with diffrent data and the results were the same. The diffrent version had been created but the data were the same as first version data.

I don't know it is a bug in Jcrom or I have done update procedure in a wrong way.
I apreciate let me know and if it is a bug it is your kindness tell me when it will be fixed.

Regurds

Maurice
 

Ólafur Gauti Guðmundsson

unread,
Jan 13, 2009, 1:25:15 PM1/13/09
to jcrom
Hi Maurice,
Are you running the official 1.3.1 release, or the latest code from
the subversion trunk?
I've fixed quite a few issues related to this in the trunk. Can you
please check out the latest version from trunk, and see if you still
have these problems?

For example, look at the TestMapping.versioningDAO() test case, and
the VersionedEntity class in the test folder. I added tests for what
you are describing, and they all pass.

One thing to be aware of is that JCROM by default creates a container
node for child nodes, and you can specify the mixinTypes for the
container node, see the annotation: @JcrChildNode(containerMixinTypes=
{"mix:versionable"})

If you still have this problem, the best solution would be if you
could write a unit test and send it to me.

Thanks!
-OGG

On Jan 9, 5:55 am, Maurice <maurice.f...@gmail.com> wrote:
> Hello there,
>
> I am trying to make versionable node for my class(Named MyTest.java). MyTest
> node has a parent node called Test. The Test node is not versionable but
> MyTest node is versionable.
> I created Test node as parent node and under it  created MyTest node and
> persisted all anottated fields in MyTest.java class in MyTest node. I did it
> by calling *create( T entity ) *method of *AbstractJcrDAO.java* class.
> By calling *update( T entity ) *method of *AbstractJcrDAO.java* class I
> Caused by: javax.jcr.UnsupportedRepositoryOperationException: *Unable to
> perform versioning operation on non versionable node: /Test*
>     at
> org.apache.jackrabbit.core.NodeImpl.checkVersionable(NodeImpl.java:3220)
>
> According the error I found that Jcrom had tried to update the parent node I
> mean the Test node. I got error because the Test node is not versionable.
>
> I changed *node =
> getSession().getRootNode().getNode(relativePath(jcrom.getPath(entity)));
>  *statment
> in *update( T entity, String childNodeFilter, int maxDepth )* method of *
> AbstractJcrDAO.java* class  to *node = getSession().getRootNode().getNode(**
> Test/MyTest**)*

Maurice

unread,
Jan 16, 2009, 2:56:13 PM1/16/09
to jc...@googlegroups.com
Hello Ólafur,

Thanks for your response. As you advised I checked out the latest code from the subversion trunk and now my code works properly.
Again I appreciate for your helpful advise.

Cheers
Maurice
Reply all
Reply to author
Forward
0 new messages