I'm trying to create a database and POJO's from my mapping files. Until now, this has worked great. But now I'm trying to assign a unique constraint to 2 columns. I read in the documentation that this can be done using <properties unique="true">. This works great for the schema generation, it does exactly what I want. However, when I let hbm2java generate java code, everything but the values between <properties> get ignored.
This is my mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="data.FiliaalDag">
<id name="FiliaalDagId" type="long" >
<generator class="identity"/>
</id>
<properties name="FiliaalDagUnique" insert="true" update="true" unique="true">
<property name="datum" type="date" not-null="true">
<meta attribute="use-in-tostring">true</meta>
</property>
<many-to-one name="filiaal" class="data.Filiaal" not-null="true">
<meta attribute="use-in-tostring">true</meta>
</many-to-one>
</properties>
<property name="klanten" type="integer" />
<property name="koopeenheden" type="integer" />
<set name="persoonlijkeData" cascade="all-delete-orphan" inverse="true">
<key column="filiaalData" />
<one-to-many class="data.VerkoperDag" />
</set>
</class>
</hibernate-mapping>
This gets generated:
Code:
public class FiliaalDag implements java.io.Serializable {
// Fields
private Date datum;
private Filiaal filiaal;
// Constructors
.... etc.
Without <properties>, this gets generated correctly:
Code:
public class FiliaalDag implements java.io.Serializable {
// Fields
private long FiliaalDagId;
private Date datum;
private Filiaal filiaal;
private Integer klanten;
private Integer koopeenheden;
private Set<VerkoperDag> persoonlijkeData = new HashSet<VerkoperDag>(0);
// Constructors
... etc
How can I set multi-column unique constraints without confusing hbm2java?
I'm using hbm2java from hibernate tools 3.2.0.beta9