James-
The CodeGenerator just generates .java file, so I don't think it will
be useful for your purposes.
Well, I suspect that if if you are currently generating classes using
CGLIB, then the easiest thing would be to just use CGLIB to add the
annotations as well.
Alternately, you could instead generate a separate orm.xml mapping
file conforming to the JPA specification, which would allow you to
define the mappings separately.
On May 14, 2007, at 11:18 AM, James Hang wrote:
Thanks for the reply Marc.
Is there a third party tool that can generate classes with
annotations?
Or is there something in OpenJPA that can do that? I noticed a
CodeGenerator class that can generate classes from metadata. Can I
use
that?
I'll take a look at the PCClassFileTransformer class like you
suggested.
Thanks for your help!
James
-----Original Message-----
From: Marc Prud'hommeaux [mailto:[EMAIL PROTECTED] On
Behalf Of
Marc Prud'hommeaux
Sent: Monday, May 14, 2007 10:30 AM
To: open-jpa-dev@incubator.apache.org
Subject: Re: Entity creation at Runtime
James-
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.
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.