- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用 ant hibernatetool 任务从 mysql 中的数据库模式生成 hbm.xml 文件。 ant 任务运行没有错误,但没有生成 hbm.xml 文件。我错过了什么......
相关配置如下:
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/config/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/config/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>
最佳答案
我遇到了同样的问题,发现以下两点很有用:
如果您想要所有表,用于匹配名称的正则表达式是“.*”,例如 <table-filter match-name=".*" package="com.sokrati.optimizer.dbaccess.optimizerConfig"/>
请注意模式名称区分大小写,因此请确保 <schema-selection>
中的大小写正确reveng.xml 中的标记。
关于java - hibernate hbm2hbmxml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/785164/
我使用 hibernate 作为 ORM 工具,我面临一个问题, 我需要将全局临时表映射到 HBM。现在,问题在于键,我知道在 hbm 中必须有一些关键字段,但是我应该输入什么,因为任何列在任何时间点
Hibernate 的常用配置文件主要分为 2 种:核心配置文件(hibernate.cfg.xml)和映射文件(Xxx.hbm.xml),它们主要用于配置数据库连接、事务管理、Hibernate 本
在我的 MSSQL 服务器中,我有一个名为 AllFavourite 的 SQL View 。为了将数据加载到我的 DTO 类中,我的 hbm.xml 文件中有以下内容... 在我的代码中
我有以下三个类: public class Student { private Integer studentId; private StudentSchool studentScho
我正在从 NHibernate 映射创建我的表和索引。 例如,我按如下方式创建姓氏索引: 我想创建一个复杂的索引,以便例如 LastName 和 FirstName 作为一个索引生成。这在 NH
我在映射我们的 byte[] 时遇到问题 field 。我一直在寻找几种解决方案,但到目前为止都没有奏效。我得到的只是这个异常(exception): The length of the byte[]
我正在通过代码使用 NHibernate 映射,并以这种方式创建 session 工厂: var mapper = new ModelMapper(); map
我的 hibernate hbm xml 有一个属性映射为 我正在使
我在屏幕上显示位图时遇到问题。当我编译并运行不显示任何内容时,尝试逐步调试,发现下面的代码是问题所在。 HBITMAP hbm = (HBITMAP)LoadImage(hInstance,
我是 hibernte 新手。我正在尝试使用 hibernate 从 oracle 表中简单检索记录。 我的实体类名为pojo1,pojo1.hbm.xml如下: 我在运行包含所有
例如, 如果我想要f
我正在通过代码使用 NHibernate 映射,并以这种方式创建 session 工厂: var mapper = new ModelMapper(); map
我有一个有两个主键的表,我如何在 hbm 映射文件中映射相同的表。如何定义两个主键。 最佳答案 两个主键?您可能指的是复合主键。检查this here . 关于java - 如何在 hbm 中定义
我是 hibernate 新手,遇到了一个问题。我已经阅读了 hibernate 网站上的入门指南等所有内容,但仍然无法找到解决方案。 我有一堂这样的课: public class ResultTre
我在打开 hbm 文件时遇到这个奇怪的问题。我正在使用 hibernate3.jar。我还验证了类路径中只有一个 hibernate3.jar 并且它包含 hibernate 映射 dtd 文件。 我
你能否让 1 个表被映射到 2 个不同类的 2 个不同的 HBM 引用(它们是不相关的,基本类,没有继承)。 我知道由于重复,这可能是不好的做法,但它与代码维护有关。我试图避免删除其中一个类。 谢谢,
例如, 如果我想要f
我正在开发一个 Spring 框架和 hibernate 应用程序,其中包含一个企业 Web 应用程序的中央数据库,该应用程序具有每天约有 1000 位用户在线。 您可以假设有一个计费应用程序,任何人
我是 Hibernate 新手,正在尝试插入 ArrayList在数据库中使用 .hbm 映射文件。我不想使用任何注释。我搜索了如何插入 ArrayList并从 here 找到工作代码。 我期待一个包
我在谷歌上搜索了很多,并且遵循了很多关于它的教程,但我没有让它工作。我在表 Player 和 Type 之间有多对多关系。两个表都通过 typeperplayer 连接。在表中 typeperplay
我是一名优秀的程序员,十分优秀!