Domanda

I'm back here in Stackoverflow wondering what the difference is between values in and within a Hibernate's hbm.xml file.

I explain myself a little better:

<property column="LOGIN_NAME" generated="insert" lazy="false" name="loginName" not-null="true" type="java.lang.String" unique="true">
    <column length="128" name="LOGIN_NAME" not-null="true" sql-type="VARCHAR(128)" unique="true"/>
</property>

In the above example I repeat some values such as not-null, unique or column-name in both <property> and <column>. My question(s) is, what's the difference? Which of those must/should be defined?

È stato utile?

Soluzione

There is no requirement to have both the tags for the same representation. Instead of writing the way you have written above following is the way to write it.

<property column="LOGIN_NAME" generated="insert" lazy="false" name="loginName" not-null="true" type="java.lang.String" unique="true" sql-type="VARCHAR(128)" length="128">
</property>

The column tag is part of the property tag itself. You only need to define it once. Its not required to add same properties again and again.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top