Hibernate 我可以在persistence.xml中声明映射吗?

Hibernate 我可以在persistence.xml中声明映射吗?,hibernate,jpa,hibernate-mapping,Hibernate,Jpa,Hibernate Mapping,我想在persistence.xml文件中声明,每个字符串类型都将映射到文本类型。 我也想声明字符集类型 我不想通过@Column…的每个属性来声明此映射。对于数据类型,没有这样的“默认”配置。你需要一个接一个地设置 如果要在persistence.xml中执行此操作,需要添加如下代码: 您的供应商 <!-- create a file that will have the mapping, in this case the file name is orm.xml

我想在persistence.xml文件中声明,每个字符串类型都将映射到文本类型。 我也想声明字符集类型


我不想通过@Column…的每个属性来声明此映射。

对于数据类型,没有这样的“默认”配置。你需要一个接一个地设置

如果要在persistence.xml中执行此操作,需要添加如下代码:

您的供应商

<!--
     create a file that will have the mapping,
     in this case the file name is orm.xml
-->
<mapping-file>orm.xml</mapping-file> 

<properties>
    <!--YOUR PROPERTIES-->
</properties>

orm.xml

使用如下代码创建一个文件:

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

    <entity class="com.uaihebert.model.test.Manufacturer">
        <attributes>
            <basic name="name">
                <!--Here you will declare your type-->
                <column  />
            </basic>
        </attributes>
    </entity>
</entity-mappings>