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.  [ 2 posts ] 
Author Message
 Post subject: can initialize a collection but not proxy
PostPosted: Thu Jul 26, 2007 2:10 am 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
I have the following method for initialize a proxy

public void initialize(Entity owner, String propertyName){
Session session = HibernateFactory.getFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
try {
tx.begin();
session.lock(owner, LockMode.NONE);
Object property = owner.executeGetter(propertyName);
Hibernate.initialize(property);

tx.commit();
} catch (Exception ex){
ex.printStackTrace();
} finally {
if (tx.isActive()) {
tx.rollback();
}

}
}

owner.executeGetter(propertyName) simply gets the referenced object using reflection.

when property is a Collection, initialize works. But when it is another object, it remains the byte enhanced version, with all its attributes uninitialized.

anything I am doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 26, 2007 9:14 pm 
Beginner
Beginner

Joined: Thu May 17, 2007 2:41 pm
Posts: 48
apparently, that is the correct behavior. the property remains a byte code enhanced version even after the initialize() call.

this differs from the case of list properties, which becomes the un-enhanced common version of List.

my problem lies else where, as I discovered.


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