openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1860) How do I get OpenJPA to use my custom classloader to load Entity classes?
Date Fri, 29 Oct 2010 14:26:21 GMT


Kevin Sutter commented on OPENJPA-1860:

As I look back on some of my questions, they didn't make sense for what you are trying to
accomplish.  Since you are trying to dynamically change the @Table annotation at runtime,
doing the OpenJPA byte code enhancement at build time would make no sense.  We would only
be doing the byte code enhancement based on the ORM mappings defined in the static code. 
So, forget about that idea.

Let's look at this differently...  Instead of attempting to modify the @Table annotations,
how about modifying an orm.xml file?  All of the ORM annotations can be represented via an
orm.xml file, which is referenced by your persistence.xml file.  So, if you have a template
orm.xml file that could be modified based on your runtime considerations and then placed in
the proper persistence archive location, then when the EMF is created, OpenJPA would reference
this orm.xml file to know what the ORM mappings should be.  Instead of relying on the annotations.

Would this approach work for your scenario?

> How do I get OpenJPA to use my custom classloader to load Entity classes?
> -------------------------------------------------------------------------
>                 Key: OPENJPA-1860
>                 URL:
>             Project: OpenJPA
>          Issue Type: Question
>          Components: jpa
>    Affects Versions: 2.0.1
>         Environment: OpenJPA 2.0.1 Java 1.6-22
>            Reporter: Hugh
> I have written a custom classloader and I can't work out how to get OpenJPA to use it
to load my entity classes.
> I've followed instructions I found to set Thread.currentThread().setContextClassLoader()
at startup before loading any EntityManager and it seems to load the OpenJPA classes and a
lot of others, but not the class I'm interested in.
> Is this the right approach?
> If so, where have I gone wrong? (
> If not, how should this be done?
> Is there some sort of guide to accomplishing this that someone could point me to?
> Thanks.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message