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.  [ 8 posts ] 
Author Message
 Post subject: remote lazy loading
PostPosted: Fri Feb 10, 2006 12:10 pm 
Newbie

Joined: Fri Feb 03, 2006 1:40 am
Posts: 11
I tried to follow the example code in Wiki article 377 on remote lazy loading.

I need some help in a couple of areas:

1. I assume that this is to solve the general problem that give an object X that has (for example) 1:n relationship with Y, then
if X is retreived in a client application (swing based) using say, a SLSB, then to get all instances of Y associated with X, you use remote lazy loading by calling x.getYSet().
Whereas this functionality is provided out-of-the-box by hibernate within the same JVM it does not work in the situation described above.

I would like this assumption to be validated.

2. So if the above is true then I presume this article shows a way to acheive remote lazy loading. If this is the case then from all the given code, I do not see the "Proxy" class being used anywhere. Am I missing something. I am not able to connect the dots in the code.

Would be thankful if someone could throw more light on this peice of code and how it can be put to practicle use in a project.

3. Even with EJB3 specs the problem of remote lazy loading is not solved.
Is this true.

Thank You.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 5:05 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
This is very experimental stuff for inspiration.

1. It is possible to cache objects on client in transaction scope cache to provide the same identity semantic as for local objects, it is important if you need "transparent" updates ( this kind of remote initialization is read only in this example).

2. Proxy class is used on client by "readResolve". I have implemented similar stuff for collections too(read only), but probably it is too large for example.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 4:50 am 
Newbie

Joined: Fri Feb 03, 2006 1:40 am
Posts: 11
I dont see LaxyReference being used anywhere in the code as well.
Can you elaborate a bit more ?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 5:06 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Object stream replaces "LazyReference" with proxy using "readResolve" on client. Client code doe's not see this stuff, it is "transparent".
But I see "ServerBean" implementation is missing on this page.

Code:
public class LazyReference implements Serializable {

    private static final long serialVersionUID = 7799616869249915673L;

    private Serializable id;

    private int token;

    private String className;

    /* package */Object readResolve() throws ObjectStreamException,
            ClassNotFoundException {

        return Proxy.create(token, Class.forName(className, false, Thread
                .currentThread().getContextClassLoader()), id);

    }


I think it is better to deploy hibernate on client using RMI/JDBC bridge than to fight with this stuff.
http://www.weblogic.com/docs51/classdocs/JDBC_RMI.html
http://rmijdbc.objectweb.org/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 11, 2006 2:09 pm 
Newbie

Joined: Fri Feb 03, 2006 1:40 am
Posts: 11
Would it possible for you to upload the mentioned missing link - the ServerBean? this will give a more complete understanding of the flow for anyone who is willing to adopt such a scheme. Yes will look into the rmi-jdbc bridge.
coming back to ejb3 entity beans, is it not a step back from ejb2 entity beans in terms of remote lazy loading?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 4:09 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I pasted all files including collections and build file. This example uses unstable hibernate API's from CVS head and you will need to modify "hibernate" package classes to make it work.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 4:23 am 
Newbie

Joined: Fri Feb 03, 2006 1:40 am
Posts: 11
Will definately need some time to understand this code. But atleast I have a good reference.

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 1:04 pm 
Newbie

Joined: Wed Feb 07, 2007 12:26 pm
Posts: 1
Hi,

I managed to figure out how to use this code in websphere, but I'm still facing some issues:

1) In HibernateServerBean.initializeCollection(String role,Serializable id)
Wrapper col = (Wrapper) context.getCollection(key);
col is always null which throws an IllegalStateExcpetion

2) Does this code also work for remote lazy loading POJOS too, or it works only for remote lazy loading collections?:

for example if class A has a many to one association with class B; A has a B getB() method, and B has a Set getAs() method, getAs() will work, and getB() will throw a LazyInitializationException


I'm using Hibernate 3.2. Has this code been written against Hibernate 3.1 or 3.2? If it has been coded with 3.1, could this be the reason of my issues?


Thanks!

Raul


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.