On 05/18/2012 08:07 AM, Jeremie BOUSQUET wrote:
Hello,
Writing a Java component that creates new XWiki pages and objects, I'd like to properly check the data before saving it to avoid some not-nice-and-avoidable exceptions to occur.
Seems that in XWiki mappings, a StringProperty is limited to 255 chars and a LargeStringProperty to 60000
But as it's a hibernate mapping (meaning it's customizable by users), and also as it can possibly change with future versions of XWiki, I'd like to know if there is an easy way to programmatically check for the maximum authorized length of these fields from a Java component ? I'd prefer truncating the strings before trying to save the documents (or not saving them at all) ... I had horrible times dealing with objects incorrectly created because of strings too long ... (did not check with recent xwiki though).
Well, the only way to really check this is to ask the database itself, since 60000 will sometimes be expanded to a larger data type. However, if you're using a database engine that properly supports transaction (almost anything other than MyISAM), there shouldn't be any data corruption. -- Sergiu Dumitriu http://purl.org/net/sergiu/