openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <mik...@apache.org>
Subject Re: openjpac Ant task
Date Fri, 14 Dec 2007 10:05:36 GMT
Hi Dan,

Enhancement is not database specific. The PCEnhancer ant task requires a
configuration to be specified and one of the convenient ways to do so is to
use persistence.xml. The PCEnahncer task should be able to handle a missing
configuration file, but unfortunately it doesn't at this time.

You can work around the problem by specifying a different configuration file
when you run the enhancer. Something like this should work :

    <taskdef name="enhance" classname="org.apache.openjpa.ant.PCEnhancerTask
">
        <classpath>
            <path refid="jpa.provider.cp"/>
        </classpath>
    </taskdef>

    <target name="enhance">
        <enhance>
            <!-- <config
propertiesFile="${src.location}/META-INF/persistence.xml"/>
-->
            <config propertiesFile="openjpa-dev.xml"/>
            <classpath>
                <path refid="entity.cp"/>
                <path refid="jpa.used.cp"/>
            </classpath>
            <fileset dir="${classes.location}">
                <include name="**/*.class"/>
            </fileset>
        </enhance>
    </target>

contents of openjpa-dev.xml :
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="none"/>
</persistence>

I believe that will work for you., even though it is a bit kludgy. Would you
mind opening a JIRA issue at
http://issues.apache.org/jira/browse/OPENJPAto report the problem?

There are some configuration properties which do pertain to enhancement, for
example openjpa.DetachState so there are cases where a configuration is
desirable. The task should be able to handle the absence of one though, or
at least handle something like

    <target name="enhance">
        <enhance>
             <config/>
        </enhance>
    </target>

If you don't override the defaults.

Hope this helps,
-Mike

On Dec 13, 2007 10:34 PM, Daniel Dyer <danielwdyer@dsl.pipex.com> wrote:

> I've been using the runtime agent approach for enhancing my classes and
> now I would like to switch to build-time enhancement.
>
> I'd appreciate it if somebody could help me understand exactly what is
> required.
>
> What I would like to know is what does the openjpac Ant task need the
> persistence.xml for?  Is enhancement specific to the particular database
> that I am using?  There is apparently no other information in there that
> could be useful (I already specify which classes to look at by providing a
> fileset to the Ant task).
>
> My problem is that when I add the persistence.xml to the Ant task, it
> fails because I have specified the <jar-file> element and the JAR file it
> references does not exist yet (how can it? I have to enhance the classes
> before packaging them in a JAR).  If I don't provide the persistence.xml
> it fails because "MetaDataFactory could not be configured".  I suppose I
> could create a different persistence.xml just for this step, but is it
> necessary?
>
> Also, currently (with the runtime agent enhancement) I am using the same
> entity classes with 2 different databases (I use H2 for the unit tests and
> MySQL for the actual application).  If enhancement is database specific, I
> guess I can't do this with build-time enhancement (I would need 2 versions
> of the enhanced classes).
>
> Thanks for any insights you can give me,
>
> Dan.
>
> --
> Daniel Dyer
> http://www.uncommons.org
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message