-->
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.  [ 1 post ] 
Author Message
 Post subject: hibernate Proxy
PostPosted: Fri Oct 06, 2006 3:55 pm 
Newbie

Joined: Fri Feb 10, 2006 10:21 pm
Posts: 5
hi,

I want to iterate over a collection of elements of a hierarchy, and in the mapping the most general class was used.
I want to do instanceof on these elements to do specific code.
I read on http://www.hibernate.org/280.html that a visitor pattern is the best solution. But in my case it would brought a lot of overhead. I decided to create a method in all entities that return the element(not proxy).

eg

public Entity getThis(){
return this;
}

but the object returned was the proxy. So I modificated this method to

public void getThis(List lista){
lista.add(this);
}

In this case the list was returned and I could get the element with get(0) on the list.

But my doubt is: if I get the entity off proxy and work with this. What is the problems that I can have.

I know that proxy is used to lazy initialize. But in my tests I get the entity off proxy I had a collection in this entity no initialized(PersistentBag) and when I needed to use this it was lazily initialized.

Whats the importance of the proxy besides this? What problem could I have if I continue in this manner?

thanks


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.