2009-04-24 4 views
3

나는 개미 hibernatetool 작업을 사용하여 MySQL의 db 스키마에서 hbm.xml 파일을 생성하려고한다. ant 태스크는 오류없이 실행되지만 hbm.xml 파일은 생성되지 않습니다.hibernate hbm2hbmxml

의 build.xml

<taskdef name="hibernatetool" 
    classname="org.hibernate.tool.ant.HibernateToolTask" 
    classpathref="3p-classpath"> 
</taskdef> 

<target name="hbmxmlgen" 
    description="Creating hbm xml files from DB"> 
    <hibernatetool> 
     <jdbcconfiguration 
      configurationfile="src/config/hibernate.cfg.xml" 
      revengfile="src/config/hibernate.reveng.xml" 
      detectmanytomany="true"> 
     </jdbcconfiguration> 
     <hbm2hbmxml destdir="${mappings.dir}"/> 
    </hibernatetool> 
</target> 

SRC/설정/hibernate.cfg.xml로

<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE hibernate-configuration PUBLIC 
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> 
    <session-factory> 
     <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="connection.url">jdbc:mysql://localhost/?useUnicode=true&characterEncoding=utf8</property> 
     <property name="connection.username">root</property> 
     <property name="connection.pool_size">1</property> 
     <property name="dialect">org.hibernate.dialect.MySQLDialect</property> 
     <property name="current_session_context_class">thread</property> 
     <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 
     <property name="show_sql">true</property> 
    </session-factory> </hibernate-configuration> 

SRC/설정 : 내가 놓친 거지 ... 여기

는 관련 coonfigurations 있습니다 /reveng.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd"> 

<hibernate-reverse-engineering> 
    <schema-selection match-schema="optimizer_config"/> 
    <type-mapping> 
     <sql-type jdbc-type="VARCHAR" hibernate-type="string"/> 
     <sql-type jdbc-type="NUMERIC" hibernate-type="java.lang.Long" /> 
     <sql-type jdbc-type="INTEGER" hibernate-type="java.lang.Integer" /> 
     <sql-type jdbc-type="DECIMAL" hibernate-type="java.lang.Double" /> 
    </type-mapping> 
    <table-filter match-name="*" package="com.sokrati.optimizer.dbaccess.optimizerConfig"/> 
</hibernate-reverse-engineering> 

답변

1

table-filter이 잘못되었다고 생각합니다.

시도 :

<table-filter match-name="%" package="com.sokrati.optimizer.dbaccess.optimizerConfig"/> 
0

<property name="connection.username">ROOT</property> 
2

을 시도 저도 같은 문제를 가지고하고 유용한이 개 다음 사항을 발견

  1. 에 일치하는에 사용하는 정규 표현식 이름이 모든 테이블을 원한다면 '. *'예 <table-filter match-name=".*" package="com.sokrati.optimizer.dbaccess.optimizerConfig"/>

  2. 는 스키마 이름은 대소 문자를 구분주의, 그래서 경우 reveng.xml<schema-selection> 태그에 올바른지 확인하십시오.

0

다음 두 가지 사항을 확인할 수 있습니까?

  1. claaspath에서 mysql 드라이버 jar의 올바른 버전을 유지하십시오. (예를 들어, mysql 5.x를 사용하고 있다면 mysql driver jar의 해당 버전이 필요합니다. 때때로 이전 버전의 jar에서는 오류가 발생하지 않지만 예상대로 작동하지는 않습니다.)

  2. 가능하면 수정하십시오 재산과 같은 :

    <property name="connection.url">jdbc:mysql://localhost:3306/?useUnicode=true&characterEncoding=utf8</property>
0

사소한 문제. 비슷한 문제를 겪고있었습니다. 이상한 나는 테이블 필터에 대해 exclude = "false"를 지정해야하고 나를 위해 일했다.

관련 문제