-
1. Re: onetomany stuff is coming when?
adamw Oct 1, 2009 1:44 PM (in response to deanhiller)Hello,
9.3 in the manual only refers to one special case, of a @OneToMany+@JoinColumn annotation combination.
The behavior you are asking about depends on the org.hibernate.envers.revisionOnCollectionChange setting, which defaults to false. Then, if you add a new dog to the collection of dogs in a person, or remove a dog, both the dog AND the person will have a new revision generated.
However, if you change a dog, without changing its owner (for example change the age field), only the dog will have a new revision generated, not the person.
Adam -
2. Re: onetomany stuff is coming when?
deanhiller Oct 5, 2009 9:59 AM (in response to deanhiller)Is there a way we can add a setting for this as well(changeParentIfChildChanges=true)? If not, is there a way we can add a patch here to allow this functionality. for us, this would be awesome.
Context: We have a requirements document with requirements in it so a change to any requirement would generate a new version of the document as well, otherwise, the history of requirement doc would be wrong. ie. We version the requirement itself and the document and we need to have a history of changes to the document.
thanks,
Dean -
3. Re: onetomany stuff is coming when?
deanhiller Oct 5, 2009 10:07 AM (in response to deanhiller)Also, so if I have a Person Mike with 3 dogs, A, B, and C at time point X, and then we change C's name to D at time point Y. Later, I try to query the history for time point X, it is going to show Person with A, B, and D dogs which is incorrect? It should show at point X person has A, B, and C dogs.
hmmm, my first guess would be not to edit dogs but always delete and persist a new one, but then my dogs themselves are not versioned :( and I want that as well. this just sounds like it kind of doesn't work very well, but is very close to working.
thanks for any info here! Also, what part of the source code would we start with to try to create a patch here? My gut tells me it would be easier to patch envers and use that then it would be to go forward with out current design as envers would eliminate ALOT of code on our project AND make it very straightforward as it is very confusing right now.
thanks,
Dean -
4. Re: onetomany stuff is coming when?
adamw Oct 6, 2009 8:29 AM (in response to deanhiller)Hello,
well, it really depends on what you want to do. If you have a person P with dog D, and you modify the dog to a different name (keeping the relation to the person unchanged), then a new revision will be generated only for D. There's no need to generate a revision for P, as it didn't change (it would just unnecessarily duplicate the data, and anyway, how would you know when to stop generating revisions for relations?)
However, if you later read the person P at the revision at which you modified the dog, and you read the relation to dog, it will show the correct, modified version. So if you read an object at revision X, it will show you the content and the relations as they were then.
Adam -
5. Re: onetomany stuff is coming when?
deanhiller Oct 6, 2009 9:47 AM (in response to deanhiller)oh, very interesting. If I get a person for time X via query and time Y via query, then envers must be storing the date or version in the cross-ref table? so that when I try and go get the dogs for the person at time X and person at time Y, X will result in A,B,C and Y will result in A,B,D....perfect...exactly what we want!!!
quite nice!!!!! hmmm, we will definitely have to try this project out...AWESOME!!!!
One more question...If there is not a new person and only a new cross-ref which I would assume you would have to have mapping X to ABC and Y to ABD to provide this functionality, I assume I could easily query on how many versions there are of Person in the sense that person at time X and time Y are different??? ie. different version numbers.
ie. I need to display the history of the requirements document and person at time x and y would each be a different version of the doc even though the properties of the doc have not changed....just requirements in the doc have changed.
THANKS ALOT FOR YOUR HELP!!!!!
thanks,
Dean -
6. Re: onetomany stuff is coming when?
adamw Oct 7, 2009 10:08 AM (in response to deanhiller)Hello,
yes, the revisions table stores the date and other metadata.
I don't quite understand the second question. You can retrieve the history (or the length of it) of an entity with the queries.
Adam