Hi,
I'm trying to persist a variable subclass based on an interface. I'm getting Could not instantiate component with CGLIB: packagename.Mobile
Any ideas?
I have the following file structure:
Subscriber.java - class containing component reference to Address interface. Subclass of User.java
AddressFactory.java - factory creating addresses based on created string name, based on locale
Address.java - interface containing component reference to mobile.java
AnAddress.java - abstract class
NLAddress.java - implementation class
MobileFactory.java - factory creating mobiles based on created string name, based on locale
Mobile.java - interface
AMobile.java - abstract class
NLMobile.java - implementation class
Hibernate version:2.1
***Subscriber.java
/**
* @hibernate.component
* @return Returns the address.
*/
public Address getAddress() {
return address;
}
***AddressFactory.java
public static Address getAddress(Locale locale){
try{
return (Address) Class.forName("nl.msw.dates4free.business.entities.address." + locale.getCountry() + "Address").newInstance();
***Address.java
public interface Address {
/**
* @hibernate.component
* @return
*/
public abstract Mobile getMobile();
/**
* @param newVal
*
*/
public abstract void setMobile(Mobile newVal);
***AnAddress.java
public Mobile getMobile() {
return mobile;
}
***NLAddress.java
public NLAddress(){
mobile = MobileFactory.getMobile(new Locale("NL", COUNTRY_CODE));
}
public void setMobile(Mobile newVal) {
mobile = newVal;
}
The "mobile stack" is identical.
***MobileFactory
public static Mobile getMobile(Locale locale){
try{
return (Mobile) Class.forName("nl.msw.dates4free.business.entities.address." + locale.getCountry() + "Mobile").newInstance();
***Mobile.java
public void setMobile(String number) throws MobileNumberFormatException;
/**
* @hibernate.property length="25"
* @return
*/
public String getMobile();
***AMobile.java
public String getMobile() {
return mobile;
}
public void setMobile(String mobile)throws MobileNumberFormatException{
this.mobile = mobile;
}
***NLMobile.java
public NLMobile(){}
public void setMobile(String number) throws MobileNumberFormatException{
.....
super.setMobile(mob);
}
Mapping documents: User.hbm.xml <component name="address" class="nl.msw.dates4free.business.entities.address.Address" >
<component name="mobile" class="nl.msw.dates4free.business.entities.address.Mobile" >
Thanks,
Marc
|