-
1. Weak referencies store/retrieve
rhauch Feb 4, 2011 10:29 AM (in response to dimonv)That sounds odd, but all of what you're seeing is certainly possible if the WEAKREFERENCE property is somehow being turned into a REFERENCE property. This clearly sounds like a bug, so please log an issue in JIRA.
Are you using a node type with a WEAKREFERENCE or REFERENCE property definition? If so, can you share it?
Can you provide the sample code that sets the property, retrieves the node and property, and performs the comparison? Doesn't need to be a full-on test case; code snippets would be enough for us to know exactly what you're doing so we can replicate it.
Thanks!
-
2. Weak referencies store/retrieve
dimonv Feb 4, 2011 10:55 AM (in response to rhauch)Here is s snapshot of the relevent node type definition:
['org:identity'] > nt:unstructured, mix:referenceable , mix:shareable
['org:person'] > 'org:identity', mix:referenceable, mix:shareable
...
['org:identity-group'] > 'org:identity'
- 'org:name' (String) mandatory
- 'org:members' (weakreference) = 'org:person' MULTIPLE INITIALIZE
and the codesnippet of the property assignment:
Node groupNode; //"org:identity-group"
Node person; // "org:person"
...
Set<Value> membersSet = new HashSet<Value>();
if (groupNode.hasProperty("org:members")) {
Value[] members = groupNode.getProperty("org:members").getValues();
List<Value> membersList = Arrays.asList(members);
membersSet.addAll(membersList);
}
Value newMember = getSession().getValueFactory().createValue(person.getIdentifier(), PropertyType.WEAKREFERENCE);
membersSet.add(newMember);
Value[] membersValues = new Value[membersSet.size()];
membersValues = membersSet.toArray(membersValues);
groupNode.setProperty("org:members", membersValues, PropertyType.WEAKREFERENCE);
getSession().save();
getSession().logout();
If I retrieve the groupe node:
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query q = queryManager.createQuery("SELECT * FROM 'org:identity-group' WHERE ('org:name' = '" + name + "')"
, "JCR-SQL2");
javax.jcr.query.QueryResult result = q.execute();
Node groupNode = null;
for (NodeIterator ni = result.getNodes(); ni.hasNext();) {
groupNode = ni.nextNode();
}
return groupNode;
Anyway between assignment, storing or retrievig the type of the value switches from WEAK- to REFERENCE.
I hope it'll help.
-
3. Weak referencies store/retrieve
rhauch Feb 4, 2011 11:56 AM (in response to dimonv)That's exactly what we'll need to reproduce. Thanks!
-
4. Weak referencies store/retrieve
dimonv Feb 7, 2011 4:30 AM (in response to rhauch)I'm not sure but I have a suspicion that it is the method org.modeshape.jcr.SessionCache.findBestPropertyDefintion(...) which chooses a wrong property type.
-
5. Weak referencies store/retrieve
rhauch Feb 9, 2011 9:31 AM (in response to dimonv)Thanks. I logged this as MODE-1092 and targeted it as critical for the next release.
-
6. Re: Weak referencies store/retrieve
dimonv Feb 11, 2011 10:39 AM (in response to dimonv)I think I got a solution for it. See my comments to MODE-1092.
-
7. Re: Weak referencies store/retrieve
rhauch Feb 14, 2011 1:48 PM (in response to dimonv)As mentioned on MODE-1092, I have a pull-request for the changes to fix this, and am waiting for a review. Stay tuned.
-
8. Re: Weak referencies store/retrieve
dimonv Feb 15, 2011 4:58 AM (in response to rhauch)Since I'm not familiar with GitHub, could you write me what does it mean and if you expect any actions from my side?
-
9. Re: Weak referencies store/retrieve
rhauch Feb 15, 2011 8:49 AM (in response to dimonv)No, you don't need to do anything at the moment. Our Git repository on GitHub is our master repository, and once we have some 'proposed' changes that appear to work, we create a GitHub pull request with those changes and ask that some other developer review the changes. Once approved, we'll merge it into the 'master' branch on the official GitHub repository.
My previous post was just to keep you (and anyone else) informed of the progress.
-
10. Weak referencies store/retrieve
rhauch Feb 15, 2011 3:07 PM (in response to rhauch)The fix for MODE-1092 has been committed to the 'master' branch, and will be included in the next release. I've marked the issue as resolved, but if you're able to test 'master' and still find a problem, please reopen the issue.
Thanks again, Dmitri, for all the help with this issue!
-
11. Weak referencies store/retrieve
dimonv Feb 17, 2011 3:57 AM (in response to rhauch)You're welcome, Randall. Thank you for the fast fixing. Community is great:-)