Hello,
We move from Kodo to Hibernate and because proxies did not meet the requirements of our business layer (narrowing proxy and casting problems), we decided to use bytecode enhancement in order to avoid lots of changes in our business layer.
However, lazy loading interception does not work for us.
What I did is I put
Code:
@org.hibernate.annotations.Proxy(lazy = false)
annotation on every entity class and
Code:
@org.hibernate.annotations.LazyToOne(org.hibernate.annotations.LazyToOneOption.NO_PROXY)
annotation on every field that that is
Code:
@ManyToOne
or
Code:
@OneToOne
association, so it looks in most cases like:
Code:
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
@org.hibernate.annotations.LazyToOne(org.hibernate.annotations.LazyToOneOption.NO_PROXY)
(We had to put that cascade because Kodo used defferred constraints mechanism which is unavailable in Hibernate afaik)
Bytecode Instrumentation task worked and modified compiled classes what can be seen after decompiling.
However if I run a JPQL query like
Code:
select a from Account a where a.name = 'Account_1'
select queries for every @ManyToOne association are issued as well.
Are we missing something important?
We use Hibernate 4.2.18