I spent the last week or so figuring out very strange behavior which I could not explain. I’m not sure if any sort of code would be helpful so I just explain what the situation is:
We have a class “caseClass” containing (among others) the following DBList:
Name = product
Pretty Name = product
Custom Display =
{{velocity}}
#set ($propertyClass = $object.getxWikiClass().get($name))
#if ($type == 'edit')
{{html clean=false}}
$doc.displayEdit($propertyClass, $prefix, $object)
{{/html}}
#else
#set($listMap=$propertyClass.getMapValues())
#foreach($fieldKey in $object.getProperty($name).value)
#set($fieldValue=$listMap.get($fieldKey).getValue())
[[${fieldValue}>>$services.PropertyManager.getSourceURL(${fieldKey})]]
#end
#end
{{/velocity}}
DisplayType = select
Multiple Select = true
Since of box = 10
Multiselect seperators = []
- empty
Join seperator = ,
Sort = none
Relational Storage = true
Cache = false
Hibernate Query =
SELECT idVarProp.value, CONCAT(codeVarProp.value, ' - ', naamVarProp.value, ' (', codeProdProp.value, ' - ', naamProdProp.value, ')')
FROM BaseObject obj, StringProperty idVarProp, StringProperty codeVarProp, StringProperty naamVarProp, StringProperty idVarProdProp,
BaseObject obj2, StringProperty idProdProp, StringProperty codeProdProp, StringProperty naamProdProp
WHERE obj.className = 'PDCKlassen.VariantClass' AND
obj2.className = 'PDCKlassen.ProductClass' AND
idVarProp.id.id = obj.id AND idVarProp.id.name = 'identificatieString' AND
codeVarProp.id.id = obj.id AND codeVarProp.id.name = 'codeVariant' AND
naamVarProp.id.id = obj.id AND naamVarProp.id.name = 'naamVariant' AND
idVarProdProp.id.id = obj.id AND idVarProdProp.id.name = 'product' AND
idProdProp.id.id = obj2.id AND idProdProp.id.name = 'identificatieString' AND
codeProdProp.id.id = obj2.id AND codeProdProp.id.name = 'productCode' AND
naamProdProp.id.id = obj2.id AND naamProdProp.id.name = 'naam' AND
idVarProdProp.value = idProdProp.value AND
obj.name <> 'PDCKlassen.VariantTemplate' AND obj2.name <> 'PDCKlassen.ProductTemplate'
ORDER BY codeProdProp.value, codeVarProp.value
XWiki Class name = []
- empty
Id Field Name = []
- empty
Value Field Name = []
- empty
The functional side is obviously, that this field can contain 0 - n occurrences.
We have a java based listener that is used to save pages with one (exactly one) object of this class on the page with a version comment:
xwikiContext.getWiki().saveDocument(XWikiDocument, comment, true, xwikiContext)
The expectation is, that a new (minor) version of the page is saved with the aforementioned comment.
Situation 1: The object contains zero references (i.e. is empty)
the following a trace of what is happening:
Version 1.1 - This is the initial version After generating an event that saves the document (version 1.1) with comment "first comment" as described above the result is:
Version 1.2 - with the proper comment as passed by the save and as comment “first comment" After generating a second event that saves the document (version 1.2 this time) as above and as comment “second comment" the result is:
Version 1.2 - no change detected. The version comment is still “first comment”.
Manually editing the page and pressing save button, the result is:
Version 1.3 (minor edit selected) or Version 2.1 (minor edit not selected)
If I go back to the first step (as described after Version 1.1), the same result: the first minor version is saved, the second one is not saved.
I have checked everything up to that actual save in the XWiki class. I can see that the information passed to the saveDocument in the XWiki class is the ‘right’ data. I also tested this with minorEdit = false
and this gives a similar result
Situation 2: The DBList contains one (or more) references (i.e. is not empty)
the following is happening:
Version 1.1 - This is the initial version
After generating an event that saves the document (version 1.1) as above with comment “first comment". The results is:
Version 1.2 - with the proper comment as passed by the save and as comment “first comment"
After generating a second listener event that saves the document (Version 1.2 this time) as above and as comment “second comment", the result is:
Version 1.3 - with the proper comment as passed by the second save and the comment “second comment”
I have looked for various aspects such as comparing object, sheets and whatnot but I could not detect any difference.
Solution
Until I decided to change “Relational Storage” to false. This resulted in the proper situation (described by Situation 2 - with an empty DBList as well as an non-empty DBList)
This solution will work in our situation but we prefer to have the Relation Storage selected (true
) since we do not want to have any limitations on the size of the DBList.
Is there anyone who can explain this behavior or can confirm this is happening?