简体   繁体   English

从属性文件设置hbm.xml文件中的值

[英]Setting values in hbm.xml files from a properties file

Is it possible to set values in a hibernate.hbm.xml file from a properties file?? 是否可以从属性文件中的hibernate.hbm.xml文件中设置值?

<class name="com.company.table" table="TABLE" schema="$PROP_VALUE">
    <id name="id" type="integer">
        <column name="ID"/>
        <generator class="assigned" />
    </id>
    <property name="description" type="string">
        <column name="DESC" length="100" />
    </property>
</class>

您可以在执行时根据属性文件构造hibernate.cfg文件

并不是我所知道的,但是如果您使用的是maven,则可以使用资源插件实现类似的功能

I guess you are trying keep the schema configurable. 我猜您正在尝试保持架构可配置。 One option would be to configure this schema as a part of JDBC parameter configuration (in JDBC URL) instead of doing this in every entity definition. 一种选择是将该模式配置为JDBC参数配置的一部分(在JDBC URL中),而不是在每个实体定义中都这样做。 Please note tha this will not work if you are referring to different schemas at the same time . 请注意,如果您同时引用不同的架构,则此方法将无效。 Not sure if this is your case. 不知道这是否是您的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM