简体   繁体   中英

Play Framework 2.x not reigstering orm.xml

I have the following xml file in conf/orm.xml

<?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings>
    <entity class="models.RequestKey">
        <table name="requestKey">
        </table>
        <attributes>
            <id name="requestKeyId">
                <column name="requestKeyId" length="255"/>
            </id>
            <basic name="requestId">
                <column name="requestId" length="255"/>
            </basic>
            <basic name="key">
                <column name="key" length="255"/>
            </basic>
        </attributes>
    </entity>
</entity-mappings>

Play framework is not picking up or registering the orm XML settings, even when the xml syntax is bad. Documentation says

"Note that Ebean will also make use of a conf/orm.xml file (if present), to configure entity-mappings."

I get the following error when I attempt to interact the aforementioned bean

"[RuntimeException: No @javax.persistence.Id field found in class [class models.RequestKey]]"

Specifically, the error is thrown in this code

public Map<RequestKey, List<RequestValue>> mapToRequestMap(UUID requestId, Map<String, String[]> queryParameters) {
        Map<RequestKey, List<RequestValue>> result = new HashMap<RequestKey, List<RequestValue>>();

        queryParameters.forEach((key, values) ->  {
            RequestKey requestKey = new RequestKey(UUID.randomUUID(), requestId, key);

            List<RequestValue> requestValues = Arrays.stream(values).map(
                value -> new RequestValue(UUID.randomUUID(), requestKey.getRequestKeyId(), value)
            ).collect(Collectors.toList());

            result.put(requestKey, requestValues);
        });

        return result;
    }

when result.put is called

将文件orm.xml放入conf / META-INF / orm.xml中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM