-
1. Re: Issue with Envers and composite foreign key
adamw Dec 22, 2009 7:42 AM (in response to jc1001)1 of 1 people found this helpfulCould you create a small testcase and atttach it to a JIRA issue?
Also, I don't quite understand how "using explicit annotations to map back to the User entity" would help - how would the mappings look like then?
Adam
-
2. Re: Issue with Envers and composite foreign key
jc1001 Dec 22, 2009 6:08 PM (in response to adamw)Adam,
Thanks for getting back to me. It turns out this issue is to do with lazy-loading - the Client was being lazily loaded - I assume some proxy that envers queries just had the initial -1,-1,-1 value (equivalent to null for my purposes) - when I changed the load to eager, envers gets the foreign key as expected. I'm not quite sure if this should be dismissed as a hibernate issue or flagged as an envers issue - I would have thought envers querying the one-to-one relationship from the User to the Cliet would have been enough for the proxy to load the relevant details but I don't have enough knowledge of the hibernate / envers internals to know how this happens or should happen.
When I mentioned being more explicit with the mappings I am somewhat green regarding hibernate annotations - what I meant was explicitly listing what column in the relationship owner maps to what column in the relationship target.
Is it worth raising a JIRA on this? My app is using Tapestry - what do you normally use - a skeletal Spring oriented test case?
Regards,
Jim.
-
3. Re: Issue with Envers and composite foreign key
adamw Dec 23, 2009 1:48 AM (in response to jc1001)Hello,
that certainly looks like an Envers issue - the proxy should be loaded and the values properly stored.
As for the testcase, I always use a simple console-based application (I never wrote a Spring app ). But anything that has the mappings will do.
Adam
-
4. Re: Issue with Envers and composite foreign key
jc1001 Dec 23, 2009 8:06 AM (in response to adamw)I've put together a test case which is unable to replicate the issue I am talking about - i.e. in the test case envers correctly stores the composite key of the related 1:1 entity, and can therefore load the Client related to the User object when the AuditReader is used. Debugging the non-test case, I can see that Hibernate is passing the -1,-1,-1 value to Envers (when I step through the envers source, the referenced state[] for the composite key contains -1,-1,-1) - it looks like this is some session management / caching issue that is local to my project setup and is difficult to replicate in a test case where the test case is a pure console app without the supporting framework. I am using c3p0 though not sure if this is relevant. I will raise a JIRA if I can get a working test case and until then consider it a local issue. Thanks for the feedback. -
5. Re: Issue with Envers and composite foreign key
jc1001 Dec 23, 2009 11:17 AM (in response to jc1001)I ended up getting a reproducible test case for this - executable jar and source code uploaded to https://jira.jboss.org/jira/browse/ENVERS-77 - thanks.
Regards,
Jim.
-
6. Re: Issue with Envers and composite foreign key
jc1001 Feb 8, 2010 6:16 AM (in response to jc1001)Hi,
Is there anyone working in the Envers code able to look at this issue - it's going to pop up for us quite often and it would be a shame to have to set all relevant relations to non-lazy - thanks.
Regards,
Jim.
-
7. Re: Issue with Envers and composite foreign key
adamw Feb 8, 2010 11:19 AM (in response to jc1001)I'm working on Envers from time to time, when I do get some free time from my other activities, but unfortunately I can't tell you when I'll be able to work on your problem.
Adam