-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Chapter 12.1. Proxies for Lazy Initialization
PostPosted: Wed Apr 07, 2004 6:13 am 
Beginner
Beginner

Joined: Wed Feb 18, 2004 1:28 pm
Posts: 20
Location: Rovereto - Italy
Why the documentation of Hibernate reccomend to use the class for Lazy Initialization and not the interface?

Infact:
"The mapping file declares a class or interface to use as the proxy interface for that class. The recommended approach is to specify the class itself" (Chapter 12.1)

But in the same Chapter 12.1 there are 4 reason to use Interface:
1. "Firstly, instances of Cat will never be castable to DomesticCat, even if the underlying instance is an instance of
DomesticCat."
2. "Secondly, it is possible to break proxy ==."
3. "Third, you may not use a CGLIB proxy for a final class or a class with any final methods."
4. "if your persistent object acquires any resources upon instantiation (eg. in initializers or default constructor),
then those resources will also be acquired by the proxy. The proxy class is an actual subclass of the
persistent class."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 6:28 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Whats the problem?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 7:39 am 
Beginner
Beginner

Joined: Wed Feb 18, 2004 1:28 pm
Posts: 20
Location: Rovereto - Italy
I don't understand the documentation.

I aspected:
"The mapping file declares a class or interface to use as the proxy interface for that class. The recommended approach is to specify a interface:"

not:
"The mapping file declares a class or interface to use as the proxy interface for that class. The recommended approach is to specify the class itself:"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 7:46 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Well, this is the recommended approach. You also read the list of exceptions/problems, so you now know all about it, don't you?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 8:24 am 
Beginner
Beginner

Joined: Wed Feb 18, 2004 1:28 pm
Posts: 20
Location: Rovereto - Italy
> You also read the list of exceptions/problems
>
Thank you!
But where is that list?
In chapter 6.5. Lazy Initialization?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 8:31 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You just quoted the list in your first posting! Really, whats the problem with that? There is a recommendation and some issues to watch out for, all very well documented.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 8:46 am 
Beginner
Beginner

Joined: Wed Feb 18, 2004 1:28 pm
Posts: 20
Location: Rovereto - Italy
Thank you.

Are there problems or "some gotchas to be aware of" when implementing the proxy with interfaces?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.