openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Prud'hommeaux <>
Subject Re: Entity creation at Runtime
Date Mon, 14 May 2007 17:29:36 GMT

It should be possible. The easiest way (and the most implementation- 
agnostic) would be to simply generate the classes with the  
appropriate mapping annotations, and then just load them at runtime.

The somewhat tricky part would be to ensure they get enhanced by the  
system when they are loaded. You could just run the - 
javaagent:openjpa.jar flag with no arguments, and I believe it will  
scan all loaded classes for annotations, but that can slow things  
down quite a bit. A faster solution would be to run your generated  
classes through the enhancer.

Take a look at the code for  
org.apache.openjpa.enhance.PCClassFileTransformer ... if you can't  
use that directly, then it might be good to use as a starting point.

On May 14, 2007, at 10:00 AM, James Hang wrote:

> Hi,
> I'm curious if it's possible to create and map new entities at  
> Runtime?
> We have an application which allows users to design new data models at
> runtime.  When new tables are being created in the database, we would
> like to make OpenJPA aware of them.  We are currently doing this in
> Hibernate by generating the POJO classes dynamically using CGLIB,  
> adding
> dynamically generated xml mappings to the Hibernate runtime
> configuration and re-initializing the SessionFactory.  Is there a  
> way to
> do something similar in OpenJPA?
> Thanks,
> James
> Notice:  This email message, together with any attachments, may  
> contain information  of  BEA Systems,  Inc.,  its subsidiaries   
> and  affiliated entities,  that may be confidential,  proprietary,   
> copyrighted  and/or legally privileged, and is intended solely for  
> the use of the individual or entity named in this message. If you  
> are not the intended recipient, and have received this message in  
> error, please immediately return this by email and then delete it.

View raw message