使用Hibernate .hbm.xml映射生成JPA元模型

时间:2016-07-01 19:48:59

标签: hibernate jpa metamodel

我正在尝试使用JDK 8和Hibernate 5.2.0从Hibernate映射配置(.hbm.xml)生成JPA元模型。从输出中我看到它正在寻找Hibernate Static Metamodel生成器,但它似乎没有检测到我的处理器选项或读取Hibernate映射文件,因为没有生成Metamodel源文件。

这是命令行:

javac -verbose -d "C:\Development\delta\delta\PjmBackend\interim\metamodel" 
-classpath "C:\Development\delta\delta\PjmBackend\interim\metamodel;C:\Development\delta\delta\PjmBackend\metamodel;C:\Development\delta\delta\lib\build\jpa-metamodel-generator-2.0\hibernate-jpamodelgen-5.2.0.Final.jar"
-sourcepath "C:\Development\delta\delta\PjmBackend\src"
-proc:only -processor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
-Adebug=true -AaddGeneratedAnnotation=true 
com\leeriver\trading\pjm\data\ActiveConstraint.java

这是我的META-INF / persistence.xml:

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

  <persistence-unit name="com.leeriver.trading.pjm.data.metamodel">
    <description>
      Metamodel generation for Hibernate mappings
    </description>

    <non-jta-data-source>java:app/datasources/MySqlPjmDS</non-jta-data-source>

    <mapping-file>com/leeriver/trading/pjm/data/PjmMarketData.hbm.xml</mapping-file>

    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL57InnoDBDialect" />
    </properties>
  </persistence-unit>

</persistence>

和META-INF / orm.xml:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings 
  xmlns="http://java.sun.com/xml/ns/persistence/orm"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
  version="2.0">

  <persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
  </persistence-unit-metadata>

</entity-mappings>

此输出演示了正在使用的正确静态元模型生成器:

  

注意:Hibernate JPA 2 Static-Metamodel Generator 5.2.0.Final

我从输出中得到这个警告:

  

警告:任何处理器都无法识别以下选项:&#39; [debug,addGeneratedAnnotation]&#39;

我已将-verbose标志添加到javac,并且似乎未检测到-Adebug = true。我错过了调用处理器的东西吗?有没有什么方法可以调试javac中的处理器调用,看看它是否在处理输入文件?

0 个答案:

没有答案