store entities design in new history storage and recycle bin
Hello. I would like to discuss about some aspect of my work on XWIKI-543 (recycle bin) and XWIKI-1459 (new history storage). 1. [Proposal] Use common.lang.builders & AbstractSimpleClass When i write simple entity classes (POJO), i wouldn't like to implement equals, hashcode, toString by hand for first time (it has too much duplication). commons.lang.builders has fine builders for this. These builders can do these tasks via reflections. http://commons.apache.org/lang/api-release/org/apache/commons/lang/builder/p... Can i create class "com.xpn.xwiki.util.AbstractSimpleClass" (maybe another name?) with these methods implemented via common.lang.builders (via reflections) for extending in my entities? I think it will be useful for others too. Implementation: http://rafb.net/p/G0OcJ427.html as +: + we will get equals(), hashCode() and nice toString() for free :). + we can always override these methods later if we will have some issues + we can easy switch toString() style in all extended classes - note: it is only for simple entities with no not-store specific fields. (So XWikiDocument is inapplicable i think) WDYT? 2. While i designed how to store history and recycle bin entities i found similar problems. I have following data in my entities: - id - metadata (several fields) - content (one field) One use case is fetch many metadatas for display. (i.e. history summary) Another use case is load one or several content to some hard work. (i.e. load old document from history, restore document from recycle bin) So problems is separate fetching metadata and content. How can i do it? 1) If i put all data in one class, i have to fetch all data via session.load and hql query. 2) It is possible to configure hibernate with 2 separate entity-name for one class and one table. So if we use specific entity-name, we fetch only metadata and content will be null. But i haven't tested it yet. It looks like hack. 3) solution i have for now is following: divide entity to EntityInfo and EntityContent. Both has id. You can see my solution it in patches at XWIKI-1459. Only defect is increase number of entities. Maybe there is another way? Or another design? -- Artem Melentyev
participants (1)
-
Artem Melentyev