-->
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: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 2:48 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
Hi,

Does Hibernate provide an API to enhance persistence classes? If so, could anyone point me to the javadoc please? I am having a hard time locating it.

Thanks,
Sahoo


Top
 Profile  
 
 Post subject: Re: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 4:18 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Usually with Hibernate you don't need to enhance the code (as Hibernate works with reflection).
For what purpose you intend to use a enhancer ?


Top
 Profile  
 
 Post subject: Re: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 4:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Depends what you mean by enhance.

customize the enhancer:
You can write a custom bytecode enhancer using these APIs http://anonsvn.jboss.org/repos/hibernat ... intercept/

If it's proxy enhancement, then yes we have an API to write your own proxy generator http://anonsvn.jboss.org/repos/hibernat ... ate/proxy/

But nobody use these APIs aside the Hibernate team.

execute bytecode enhancement:
We usually discourage that but you can bytecode enhance your class to provide lazy basic properties.
http://docs.jboss.org/hibernate/core/3. ... properties
There is an ant task

In Java EE, you can also use
hibernate.ejb.use_class_enhancer = true and we will enhance classes at EMF creation time

choose between cglib or javassist for enhancer:
use hibernate.bytecode.provider, it's a system level property.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 7:11 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
May be I am not using the right terminology here. Looking at the documentation, I see "No proxy fetching" [1]. What I understand by that is that, in this mode, Hibernate will not create Proxy classes for my persistence capable classes. Instead, Hibernate requires the persistence capable classes to be instrumented for lazy loading of single valued associations. I am looking for an API to instrument the classes that are part of my Java EE deployable artifact so that I can call the API while deploying it in my server which allows me to intercept deployment process. I can certainly look at the Ant task to see what APIs it uses if there is no better place to see usage of that API. Please note, Persistence.createEMF is too late for my need. I want to enhance much earlier than that.

Thanks much for responding.
Sahoo

[1] http://docs.jboss.org/hibernate/core/3. ... e-fetching


Top
 Profile  
 
 Post subject: Re: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 7:17 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It's done transparently in EE if you set hibernate.ejb.use_class_enhancer to true. That's part of the contract between JPA and the EE container.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 7:46 am 
Newbie

Joined: Wed Mar 29, 2006 3:47 pm
Posts: 17
emmanuel wrote:
It's done transparently in EE if you set hibernate.ejb.use_class_enhancer to true. That's part of the contract between JPA and the EE container.


Although it is done transparently done in EE, AFAIK it is done when container calls Persistence.createContainerEMF method, which is usually called when the application is loaded. That's too late for me. In my use case, I am not able to provide a class loader with an ability to load transformed classes. So, I am looking for a way to statically instrument the classes.

Thanks,
Sahoo


Top
 Profile  
 
 Post subject: Re: How to invoke static enhancer?
PostPosted: Thu Mar 18, 2010 8:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
sahoo wrote:
emmanuel wrote:
It's done transparently in EE if you set hibernate.ejb.use_class_enhancer to true. That's part of the contract between JPA and the EE container.


Although it is done transparently done in EE, AFAIK it is done when container calls Persistence.createContainerEMF method, which is usually called when the application is loaded. That's too late for me. In my use case, I am not able to provide a class loader with an ability to load transformed classes. So, I am looking for a way to statically instrument the classes.

Thanks,
Sahoo


Then your container does not implement EE correctly :)
Check Ejb3Configuration, it contains the code checking hibernate.ejb.use_class_enhancer and calling the enhancement.

_________________
Emmanuel


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.