[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3970?page=c...
]
Sandeep Vaid commented on HHH-3970:
-----------------------------------
This critial problem will always occur when we fetch any collection in the domain tree...
All it's one-to-one associations will be compulsorily fetched for 'n' records.
and as n increases, the problem becomes severe..
As per my knowledge, this problem is so critical and severe, that if not solved, nobody
will be able to use hibernate
efficiently (and acceptably) in real J2EE applications and hence i request for an
immediate solution for this problem..
One-to-one association must return null instead of proxy (or actual
object).
----------------------------------------------------------------------------
Key: HHH-3970
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3970
Project: Hibernate Core
Issue Type: Improvement
Affects Versions: 3.3.1
Reporter: Sandeep Vaid
Priority: Critical
In hibernate, presently one-to-one associations are fetched non-lazily...
I know that this is done because, hibernate requires to fire 1 sql to find whether proxy
can be created or not...
and if it has to fire 1 sql, then why not to load one-to-one object itself in 1 sql
instead of creating proxy of it (in 1 sql).
Consider my scenario..
Product has one-to-one with ProductBasic which has one-to-one with ProductTerm
Now i just queried for List of Products and i got say 300 product records.. (in 1 sql
query)
In this case i don;t require ProductBasic and ProductTerm.... but as these are
one-to-one associations, there are
compulsorily non-lazily fetched. Thus another 300 + 300 select queries are fired to
get ProductBasic and ProductTerm
which is surely unacceptable as there are 600 extra sql's getting fired.. The
situation may become worst if i
have many one-to-one associations in my domain tree.
I think hibernate code must be changed so that one-to-one associations should be not
compulsorily non-lazily fetched....
One way i could think of it is, if user has not asked to fetch one-to-one association
then instead of
loading one-to-one object (or creating proxy) simply null should be returned without
firing any SQL...
Later when user asks for this one-to-one association, now fire 1 sql to get this
association..
The major advantage of this approach is that if user has not asked for one-to-one
association, no extra sql (unnecessary)
queries will be fired... (specially when retriving parent collection - e.q our scenario
described above)..
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira