-->
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: CGLIB confict?
PostPosted: Fri Sep 12, 2003 12:57 pm 
Beginner
Beginner

Joined: Fri Sep 12, 2003 12:54 pm
Posts: 20
Here's a question.

I'm wanting to make fairly extensive use of CGLIB in my application, and I'm aware that Hibernate uses it.

Can anyone tell be if there will be problems enhancing an object that has already been enhanced by Hibernate? What about the reverse?

Thanks,
james


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 1:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate doesn't "enhance" objects. It uses CGLIB to create *proxies*.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 3:33 pm 
Thanks for the clarification...

Any idea how I can use CGLIB's enhancement features along with Hibernate?

I'd like the instance of the object returned by Hibernate load() to be enhanced, and I'd like Hibernate be able to save() enhanced objects.

-- or am I going to be forced to use proxies?

james


Top
  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 5:27 pm 
Beginner
Beginner

Joined: Fri Sep 12, 2003 12:54 pm
Posts: 20
...let me clarify that a bit:

If I have a class "org.foo.Foo" and I map it with Hibernate, but then enhance it at runtime, the object instances are of a type such as "org.foo.Foo$$EnhancedByCGLIB$$0" - which extends "org.foo.Foo".

Is there a way to make Hibernate go ahead and persist (save()) this object (i.e. get Hibernate to see that it doesn't have a mapping for a "com.partnet.rex.Foo$$EnhancedByCGLIB$$0" , but realize that it does have a mapping for its parent class, so go ahead and use that mapping).

Likewise for load(), can I pass it an object of type "com.partnet.rex.Foo$$EnhancedByCGLIB$$0" and a key value, and ask it to populate it?


thanks,
james


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 8:09 pm 
Beginner
Beginner

Joined: Fri Aug 29, 2003 3:39 pm
Posts: 33
Location: San Francisco, CA
jhouse wrote:
If I have a class "org.foo.Foo" and I map it with Hibernate, but then enhance it at runtime, the object instances are of a type such as "org.foo.Foo$$EnhancedByCGLIB$$0" - which extends "org.foo.Foo".

Is there a way to make Hibernate go ahead and persist (save()) this object (i.e. get Hibernate to see that it doesn't have a mapping for a "com.partnet.rex.Foo$$EnhancedByCGLIB$$0" , but realize that it does have a mapping for its parent class, so go ahead and use that mapping).

Likewise for load(), can I pass it an object of type "com.partnet.rex.Foo$$EnhancedByCGLIB$$0" and a key value, and ask it to populate it?


Those CGLIB classes are just subclasses of the original class. Hibernate should/will treat them the same way it would treat any subclass...that said, I'm not sure what the actual behavior is regarding passing in subclassed objects--have you tried it?

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 10:43 am 
herbyderby wrote:
Those CGLIB classes are just subclasses of the original class. Hibernate should/will treat them the same way it would treat any subclass...that said, I'm not sure what the actual behavior is regarding passing in subclassed objects--have you tried it?

Chris


I think hibernate will throw "persister not found"


Top
  
 
 Post subject:
PostPosted: Mon Sep 15, 2003 1:10 pm 
Beginner
Beginner

Joined: Fri Sep 12, 2003 12:54 pm
Posts: 20
Yes, that's what happens (a MappingException that says it can't find a persister for the class)


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.