0
有没有什么方法可以使用正则表达式(或只是*)来告诉Hibernate获取给定目录中甚至项目中的所有hbm.xml文件?我只是反向设计我的数据库,并且不想指定使用<映射资源=“...”>hibernate.cfg.xml映射资源
我使用Maven运行hbm2java。我是否需要在组件配置中指明某些内容?
我的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="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@....</property>
<property name="hibernate.connection.username">hithere</property>
<property name="hibernate.connection.password">shhhh</property>
<property name="hibernate.default_schema">foobar</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<mapping resource="com/foo/bar/db/Blip.hbm.xml" />
<mapping resource="com/foo/bar/db/Blap.hbm.xml" />
<mapping resource="com/foo/bar/db/Blop.hbm.xml" />
</session-factory>
</hibernate-configuration>
这是一个非常有用的答案,但很可惜,我想包含用于在它们上运行hbm2java的资源(我不知道在这个问题中指出了这一点!)然后您确认了我对可能使用正则表达式的想法。所以它不直接帮助我。但我相信别人会从中得到应用。 – Marvo 2012-03-21 18:15:08
我认为你是对的,hibernate.cfg.xml根本不支持这个。过了一段时间,事实证明,将整个hbm.xml文件列表加载到文件中是件乏味的事情,但这是一次性的事情,而且我从来没有惹过它。最后,没有那么重要。谢谢你的帮助! – Marvo 2012-05-02 21:58:06