NucleusUserException:找不到字段的映射

时间:2014-11-05 03:04:54

标签: java jdo datanucleus

我在从DB查询实体时遇到了NucleusUserException。我已经尝试了很长时间,无法弄清楚导致这个问题的原因。我希望你们中的一些人能指出我正确的方向。任何帮助将不胜感激

实体类

@PersistenceCapable(detachable = "true")
public class Position implements IsSerializable, Serializable {

    @PrimaryKey
    @Persistent
    protected String key;

    @Persistent
    protected Double quantity;

    // getter and setter omitted

}

JDO MetaData

<jdo xmlns="http://java.sun.com/xml/ns/jdo/jdo"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdo
        http://java.sun.com/xml/ns/jdo/jdo_3_0.xsd">

    <package name="org.sly.main.shared.data.finance.trading">

        <class name="Position" detachable="true" cacheable="false">
            <version strategy="version-number" />
            <field name="key" persistence-modifier="persistent"
                value-strategy="increment" primary-key="true">
                <column length="32" jdbc-type="VARCHAR" />
            </field>
            <field name="quantity" persistence-modifier="persistent" />
        </class>

    </package>
</jdo>

我用来检索的代码

PersistenceManager pm = pmf.getPersistenceManager();
Extent e = pm.getExtent(Position.class, true);
Query query = pm.newQuery(e);
query.setFilter("key == my_key");
query.declareParameters("String my_key");
Object[] params = { "1234" };
List<Position> managerList = (List<Position>) query.executeWithArray(params);

我得到的例外情况如下:

Cannot find mapping for field org.sly.main.shared.data.finance.trading.Position.key in table `POSITION` [`POSITION`.`KEY`, `POSITION`.`QUANTITY`]
org.datanucleus.exceptions.NucleusUserException: Cannot find mapping for field org.sly.main.shared.data.finance.trading.Position.key in table `POSITION` [`POSITION`.`KEY`, `POSITION`.`QUANTITY`]
    at org.datanucleus.store.rdbms.table.AbstractClassTable.addApplicationIdUsingClassTableId(AbstractClassTable.java:233)
    at org.datanucleus.store.rdbms.table.ClassTable.initializePK(ClassTable.java:1031)
    at org.datanucleus.store.rdbms.table.ClassTable.preInitialize(ClassTable.java:246)
    at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTable(RDBMSStoreManager.java:3146)
    at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTables(RDBMSStoreManager.java:2937)
    at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTablesAndValidate(RDBMSStoreManager.java:3210)
    at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:2869)
    at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:122)
    at org.datanucleus.store.rdbms.RDBMSStoreManager.addClasses(RDBMSStoreManager.java:1606)
    at org.datanucleus.store.AbstractStoreManager.addClass(AbstractStoreManager.java:954)
    at org.datanucleus.store.AbstractStoreManager.getSubClassesForClass(AbstractStoreManager.java:1693)
    at org.datanucleus.store.rdbms.sql.DiscriminatorStatementGenerator.getStatement(DiscriminatorStatementGenerator.java:306)
    at org.datanucleus.store.rdbms.scostore.JoinListStore.getIteratorStatement(JoinListStore.java:964)
    at org.datanucleus.store.rdbms.scostore.JoinListStore.listIterator(JoinListStore.java:691)
    at org.datanucleus.store.rdbms.scostore.AbstractListStore.listIterator(AbstractListStore.java:92)
    at org.datanucleus.store.rdbms.scostore.AbstractListStore.iterator(AbstractListStore.java:82)
    at org.datanucleus.store.types.backed.ArrayList.loadFromStore(ArrayList.java:294)
    at org.datanucleus.store.types.backed.ArrayList.initialise(ArrayList.java:243)
    at org.datanucleus.store.types.SCOUtils.createSCOWrapper(SCOUtils.java:256)
    at org.datanucleus.store.types.SCOUtils.newSCOInstance(SCOUtils.java:142)
    at org.datanucleus.store.rdbms.mapping.java.AbstractContainerMapping.replaceFieldWithWrapper(AbstractContainerMapping.java:399)
    at org.datanucleus.store.rdbms.mapping.java.AbstractContainerMapping.postFetch(AbstractContainerMapping.java:417)
    at org.datanucleus.store.rdbms.request.FetchRequest.execute(FetchRequest.java:420)
    at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.fetchObject(RDBMSPersistenceHandler.java:324)
    at org.datanucleus.state.AbstractStateManager.loadFieldsFromDatastore(AbstractStateManager.java:1122)
    at org.datanucleus.state.JDOStateManager.loadUnloadedFieldsInFetchPlan(JDOStateManager.java:3000)
    at org.datanucleus.state.JDOStateManager.isLoaded(JDOStateManager.java:3214)

不确定这会有所帮助,但这是在AWS Elastic Mapreduce Hadoop集群上运行的

0 个答案:

没有答案