There's this really great feature on this board to actually format code ;)
In the mapping you need to specificy the class, not the impl. In the class, simply specify the interface for the association. This is normal java semantics, a class is always castable to any interfaces it implements.
So, do:
Code:
public inteface IProduct
{
public ISupplier getSupplier();
public void setSupplier(ISupplier s);
}
public inteface ISupplier
{
public Set getProducts();
// this seems to be needed :-(
// of course, how else would hibernate "introduce this
// value into your instance. Make it private if you want...
public void setProducts(Set s);
}
public class ProductImpl implements IProduct
{
...
}
public class SupplierImpl implements ISupplier
{
...
}
<class name="ProductImpl" table="Products" >
<id name="ProductID" type="int" unsaved-value="null" >
<column name="ProductID" sql-type="int identity" not-null="true" />
<generator class="hilo" />
</id>
<many-to-one name="SupplierImpl" column="SupplierID" class="Supplier"/>
</class>
<class name="SupplierImpl" table="Suppliers" >
<id name="SupplierID" type="int" unsaved-value="null" >
<column name="SupplierID" sql-type="int identity" not-null="true" />
<generator class="hilo" />
</id>
<set name="Products" table="Products" inverse="true" cascade="all">
<key column="SupplierID" />
<one-to-many column="ProductID" class="ProductImpl" />
</set>
</class>