Given the following:
- Spring 1.2.8 (using Spring MVC)/Hibernate 3.1.3
- A QuestionMaster class containing a List of Question objects with the List index field/column “revision” (bidirectional parent/child)
- A Survey class with a List of Question objects with the List index field/column “questionNumber” (unidirectional with join table)
When editing questions, I want to detect if/when changes to a Question are made and create a new revision (i.e. new Question object that is then added to the QuestionMaster Question List) and replace the corresponding Survey Question with the new revision.
I was thinking that I could create a method in the manager/service class that tests Session.isDirty() to determine if changes were made and then create a new Question/add it to the QuestionMaster List/etc. The problem with this strategy is that I would need to cancel the changes to the original Question in the current persistence context and I’m not sure how to do that.
Any advice/suggestions?
Thanks,
Gary
|