amardeepsingh wrote:
In one of our HBM file I need to map an interface as component.
E.g.
If I have interface like this:
public interface Products
{
String getData();
setData(String s);
}
public class A
{
Products _products;
public void setProducts(Products products)
{
this._products=products;
}
public Products getProducts()
{
return _products.
}
}
In HBM File
<class name="A
table="Sample">
<component name="products">
<property name="data" type="java.lang.String"/>
</component>
</class>
If I try to load the above set it throws me an exception:
org.springframework.orm.hibernate.HibernateSystemException: Could not instantiate component with CGLIB: Products; nested exception is net.sf.hibernate.InstantiationException: Could not instantiate component with CGLIB:
Which is correct but is there any solution to build it ?
Did you try setting the class attribute of the component tag to the interface? Something like:
Code:
<class name="A" table="Sample">
<component name="products" class="Products">
<property name="data" type="java.lang.String"/>
</component>
</class>
Btw, if the XML you posted is accurate to your file, there is a missing closing double quote on the name="A portion.