openjpa enhancer fails on one-to-many, but only if its after one-to-one?

88 Views Asked by At

I get the following exception when I have my open JPA entity mapping set up with a one-to-many mapping listed after a one-to-one mapping. When I switch the order, I don't get the exception.

I'm assuming that there is an XSD rule being applied, but what is the purpose of that rule?

Failed to execute goal org.apache.openjpa:openjpa-maven-plugin:2.2.2:enhance (enhancer) on project: Execution enhancer of goal org.apache.openjpa:openjpa-maven-plugin:2.2.2:enhance failed: org.xml.sax.SAXException: Invalid content was found starting with element 'one-to-many'. One of '{"http://java.sun.com/xml/ns/persistence/orm":one-to-one, "http://java.sun.com/xml/ns/persistence/orm":many-to-many, "http://java.sun.com/xml/ns/persistence/orm":element-collection, "http://java.sun.com/xml/ns/persistence/orm":embedded, "http://java.sun.com/xml/ns/persistence/orm":transient}' is expected.

<!-- FAILED -->     
<entity class="com.test.comm">
    <table schema="dbo" name="tbl_comm_data"/>
    <attributes>
        <id name="commId">
            <column name="comm_id"/>
        </id>              
        <basic name="commName">
            <column name="comm_name"/>
        </basic>          
        <one-to-one name="CommType" target-entity="com.test.TblCommType" mapped-by="TblComm" fetch="LAZY">
            <cascade>
                <cascade-merge/>
            </cascade>
        </one-to-one> 
        <one-to-many name="CommDtls" target-entity="com.test.TblCommDtl" mapped-by="tblCommFreq">
            <cascade>
                <cascade-merge/>
            </cascade>
        </one-to-many> 
    </attributes>
</entity>



<!-- WORKED -->     
<entity class="com.test.comm">
    <table schema="dbo" name="tbl_comm_data"/>
    <attributes>
        <id name="commId">
            <column name="comm_id"/>
        </id>              
        <basic name="commName">
            <column name="comm_name"/>
        </basic>
        <one-to-many name="CommDtls" target-entity="com.test.TblCommDtl" mapped-by="tblCommFreq">
            <cascade>
                <cascade-merge/>
            </cascade>
        </one-to-many>           
        <one-to-one name="CommType" target-entity="com.test.TblCommType" mapped-by="TblComm" fetch="LAZY">
            <cascade>
                <cascade-merge/>
            </cascade>
        </one-to-one> 

    </attributes>
</entity>
0

There are 0 best solutions below