Hi,
I'm new to this whole Hibernate-thing and also in using XDoclet. So I've some questions:
I want to use a foreign key in a column. I assume that I have to use a many-to-one-association to do so. For example:
Code:
/**
* @hibernate.many-to-one column="FOOID" class="FooClass"
* @return Returns the fooID.
*/
public String getFooID() {
return fooID;
}
So in column FOOID in the current table will be a foreign key to the table that is defined in class "FooClass" (Do I have to mention the package for FooClass even if all persistent classes are in com.myPackage.pojo?). Because no column for class FooClass was defined, the id-column (primary key) is used. Right?
The next step is to define 2 columns as unique. If I get it right, that means that the combination of columnA=4 and columnB=6 can only appears once in a table.
All columns that should be unique with FOOID must have the following line?
Code:
* @hibernate.column unique-key="unique"
For example:
Code:
/**
* @hibernate.many-to-one column="FOOID" class="FooClass"
* @hibernate.column unique-key="unique"
* @return Returns the fooID.
*/
public String getFooID() {
return fooID;
}
/**
* @hibernate.property column="NAME" length="30" not-null="true"
* @hibernate.column unique-key="unique"
* @return Returns the name.
*/
public String getName() {
return name;
}
Thanks
smo