-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem persisting locale specific subclasses
PostPosted: Thu Mar 03, 2005 5:44 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.