Hibernate:无法构建实体管理器工厂(entity-mappings.xml)

时间:2015-11-02 13:34:35

标签: java xml hibernate jpa

我在桌面应用程序上使用Hibernate JPA,因为通用SQL查询几乎是不可能的,我不想实现自己的JPA。

我想使用非带注释的实体类,因为我使用的是桌面应用程序和Android应用程序共享的库,因此我希望将所有内容保存在XML中。但是,Hibernate无法构建实体管理器工厂,从而给出了以下错误。

Caused by: org.hibernate.boot.MappingException: Unable to resolve explicitly named mapping-file : com/model/entity/TransferType.xml : origin(com/model/entity/TransferType.xml)
    at org.hibernate.boot.model.process.internal.ScanningCoordinator.applyScanResultsToManagedResources(ScanningCoordinator.java:213)
    at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:81)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:194)
    at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:114)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:71)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:52)

这是我使用的映射文件xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
        version="2.0">

    <entity class="app.model.DeviceType">
        <table name="DEVICE_TYPE"
               schema="my_schema"
               catalog=""/>
        <attributes>
            <id name="type">
                <column name="type"/>
            </id>
        </attributes>
    </entity>
</entity-mappings>

我该如何解决这个问题?我在这里做错了什么?

0 个答案:

没有答案