Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/Fix: ShallowReference / HibernateUnproxyObject #558

Closed
f-aubert opened this issue Jun 28, 2017 · 10 comments
Closed

Improvement/Fix: ShallowReference / HibernateUnproxyObject #558

f-aubert opened this issue Jun 28, 2017 · 10 comments
Labels

Comments

@f-aubert
Copy link

@f-aubert f-aubert commented Jun 28, 2017

I noticed another small thing, and although not a big problem, I'd like to reference it. When dealing with shallow references, it should be possible, at least in theory, to work with hibernate proxy and not having to hit the database just to compare the id itself as per shallow reference definition... As of now, 3.3.2, I notice each commit involving a change in an Entity referring another one with ShallowReference on a Proxy triggers the load of the proxy... Thx for your time.

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jun 28, 2017

ok, could you push a test case with a reproduction of this issue?

@f-aubert
Copy link
Author

@f-aubert f-aubert commented Jun 30, 2017

Here is my first attempt at uploading a Patch to apply to Javers in order to demonstrate my UseCase. Please forgive me if I did miss something. I can correct it and submit it again, as now I have a working Javers checkout. It works best to run tests one at a time.

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jul 1, 2017

It would be easier if you push this code to github (to your fork of javers repository)

@f-aubert
Copy link
Author

@f-aubert f-aubert commented Jul 2, 2017

I didn't intend to push one more project "and pollute github" just to show my test case, but if it helps, I will do it tomorrow.

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jul 2, 2017

Fork is not another project, it's more like a branch

@f-aubert
Copy link
Author

@f-aubert f-aubert commented Jul 3, 2017

Although I have the feeling to be copying your work, just for the sake of showing you a test case, I did it. https://github.com/f-aubert/javers

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jul 3, 2017

That's fine, thanks , that's the way we work on github

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jul 17, 2017

just a link to your commit

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jul 17, 2017

Ok, so looks like we can get the id and persistent class from a proxy without initializing it. So the issue is doable

    println "proxy.isInitialized: " + Hibernate.isInitialized(mathsRef)
    println "proxy.class: " + mathsRef.getClass()
    println "proxy.id: " + mathsRef.getId()
    println "proxy.persistenClass: "+ mathsRef.getHibernateLazyInitializer().getPersistentClass()
    println "proxy.isInitialized: " + Hibernate.isInitialized(mathsRef)
    println 'I am happy :)'
proxy.isInitialized: false
proxy.class: class org.javers.spring.boot.sql.Course_$$_jvstfba_1
proxy.id: 1
proxy.persistenClass: class org.javers.spring.boot.sql.Course
proxy.isInitialized: false
I am happy :)
bartoszwalacik added a commit that referenced this issue Jan 13, 2018
bartoszwalacik added a commit that referenced this issue Jan 13, 2018
bartoszwalacik added a commit that referenced this issue Jan 13, 2018
bartoszwalacik added a commit that referenced this issue Jan 13, 2018
#558 issue
@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jan 14, 2018

fix released in 3.7.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.