You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Patrice DUROUX (Jira)" <ji...@apache.org> on 2021/11/10 14:33:00 UTC

[jira] [Created] (OPENJPA-2887) trouble mapping a map field using an XML ORM

Patrice DUROUX created OPENJPA-2887:
---------------------------------------

             Summary: trouble mapping a map field using an XML ORM
                 Key: OPENJPA-2887
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2887
             Project: OpenJPA
          Issue Type: Bug
          Components: Enhance
    Affects Versions: 3.2.0, 3.1.2
            Reporter: Patrice DUROUX


Hi,

On a property field (locations) that is a Map<C1, C2> where C1 has a id class (composite key) that is an embeddable:

 

But now if I try to apply the following mapping:

    <entity class="Sequence">
        <table name="sequences" />
        <attributes>
            <id name="id">
                <column name="sequence_id" />
                <generated-value strategy="IDENTITY" />
            </id>
            <many-to-many name="locations">
                <map-key-join-column name="numacc" />
                <map-key-join-column name="feanum" />
                <join-table name="locations">
                    <join-column name="sequence_id" />
                    <inverse-join-column name="class_id" />
                </join-table>
            </many-to-many>
        </attributes>
    </entity>

Mapping is like loosing the "numacc" column while trying to insert values:

 

Caused by: <openjpa-3.2.0-r6f721f6 fatal general error> org.apache.openjpa.persistence.PersistenceException: (conn=64888979) Field 'numacc' doesn't have a default value \{prepstmnt 2064897338 INSERT INTO imgt2.locations (sequence_id, class_id, feanum) VALUES (?, ?, ?)} [code=1364, state=HY000]

 

It is remaining me an old issue #1893 of mine where also some columns were lost in translation. ;)

I admit myself being a little lost in among all the <map-key-*> elements. Am I doing it right?

 

A current working solution is to not have the 2 elements <map-key-join-column /> in the mapping and use the default JPA column names that are 'key0_numacc' and 'key0_feanum' as the physical column names in the corresponding table. But this is not the expected solution.

 

Thanks,
Patrice



--
This message was sent by Atlassian Jira
(v8.20.1#820001)