I'm struggling to solve the error I've been receiving.  In overview, I have two 
types of people in the system, Provider and Clients.  A Provider can have many 
ProviderContacts and a Client can have many ClientContacts.  When I attempt to 
load a Client (which has a mapped collection to ClientContacts), I get an error.

This is the query I'm running:

  | SELECT c 
  | FROM Client c 
  | WHERE c.relationship.relationshipId LIKE :expression OR
  |               c.taxId LIKE :expression OR 
  |               c.clientName LIKE :expression
  | 

This is the error I receive ...

  | 14:41:37,846 ERROR [BasicPropertyAccessor] IllegalArgumentException in 
class: com.tasconline.client.ClientContact, setter method of property: client
  | 14:41:37,846 ERROR [BasicPropertyAccessor] expected type: 
com.tasconline.client.Client, actual value: com.tasconline.provider.Provider
  | 14:41:37,846 INFO  [DefaultLoadEventListener] Error performing load command
  | org.hibernate.PropertyAccessException: IllegalArgumentException occurred 
while calling setter of com.tasconline.client.ClientContact.client
  |         at 
org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
  |         at 
org.hibernate.tuple.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:330)
  |         at 
org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:188)
  |         at 
org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3231)
  |         at 
org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:126)
  |         at 
org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
  |         at org.hibernate.loader.Loader.doQuery(Loader.java:717)
  |         at 
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
  | 
  | 

This is the Client entity:

  | @Entity
  | @Table(name="tasc_client")
  | @Inheritance(strategy=InheritanceType.JOINED,
  |              discriminatorValue="Client")
  | @PrimaryKeyJoinColumn(name="fk_tasc_relationship_binding")
  | public class Client extends RelationshipBinding {
  |     
  |     private static final String BINDING_TYPE = "Client";
  |     
  |     private TaxId taxId;
  |     private TaxFilingStatus taxFilingStatus;
  |     private OrganizationName clientName;
  |     private Address shippingAddress;
  |     private Address billingAddress;
  |     private Collection<ClientContact> contacts;
  |     
  |     /**
  |      * 
  |      */
  |     public Client() {
  |         this.bindingType = BINDING_TYPE;
  |         this.contacts = new LinkedList<ClientContact>();
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @Embedded
  |     @AttributeOverride(name="id", [EMAIL PROTECTED](name="taxId"))
  |     public TaxId getTaxId() {
  |         return(this.taxId);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setTaxId(TaxId taxId) {
  |         this.taxId = taxId;
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @Transient
  |     public TaxFilingStatus getTaxFilingStatus() {
  |         return(this.taxFilingStatus);
  |     }
  | 
  |     /**
  |      * 
  |      */
  |     @Transient
  |     public void setTaxFilingStatus(TaxFilingStatus taxFilingStatus) {
  |         this.taxFilingStatus = taxFilingStatus;
  |     }
  |     
  |     /**
  |      *
  |      */
  |     @Column(name="taxFilingStatus")
  |     public String getTaxFilingStatusType(String taxFilingStatusType) {
  |         if (this.taxFilingStatus == null) return(null);
  |         return(this.taxFilingStatus.name());
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setTaxFilingStatusType(String taxFilingStatusType) {
  |         if (taxFilingStatusType == null) {
  |             this.taxFilingStatus = null;
  |             return;
  |         } else {
  |             for (TaxFilingStatus status: TaxFilingStatus.values()) {
  |                 if (status.name().equals(taxFilingStatusType)) {
  |                     this.taxFilingStatus = status;
  |                     return;
  |                 }
  |             }
  |             throw new IllegalArgumentException
  |                 ("Invalid TaxFilingStatus: " + taxFilingStatusType);
  |         }
  |     }
  |      
  |     /**
  |      * 
  |      */
  |     @Embedded
  |     @AttributeOverride(name="name", [EMAIL PROTECTED](name="clientName"))
  |     public OrganizationName getClientName() {
  |         return(this.clientName);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setClientName(OrganizationName clientName) {
  |         this.clientName = clientName;
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @Embedded
  |     @AttributeOverrides({
  |         @AttributeOverride(name="address1", [EMAIL 
PROTECTED](name="shippingAddress1")),
  |         @AttributeOverride(name="address2", [EMAIL 
PROTECTED](name="shippingAddress2")),
  |         @AttributeOverride(name="city", [EMAIL 
PROTECTED](name="shippingCity")),
  |         @AttributeOverride(name="stateAbbreviation", [EMAIL 
PROTECTED](name="shippingState")),
  |         @AttributeOverride(name="deliveryArea", [EMAIL 
PROTECTED](name="shippingDeliveryArea")),
  |         @AttributeOverride(name="plusFour", [EMAIL 
PROTECTED](name="shippingPlusFour"))
  |     })
  |     public Address getShippingAddress() {
  |         return(this.shippingAddress);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setShippingAddress(Address shippingAddress) {
  |         this.shippingAddress = shippingAddress;
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @AttributeOverrides({
  |         @AttributeOverride(name="address1", [EMAIL 
PROTECTED](name="billingAddress1")),
  |         @AttributeOverride(name="address2", [EMAIL 
PROTECTED](name="billingAddress2")),
  |         @AttributeOverride(name="city", [EMAIL 
PROTECTED](name="billingCity")),
  |         @AttributeOverride(name="stateAbbreviation", [EMAIL 
PROTECTED](name="billingState")),
  |         @AttributeOverride(name="deliveryArea", [EMAIL 
PROTECTED](name="billingDeliveryArea")),
  |         @AttributeOverride(name="plusFour", [EMAIL 
PROTECTED](name="billingPlusFour"))
  |     })
  |     public Address getBillingAddress() {
  |         return(this.billingAddress);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setBillingAddress(Address billingAddress) {
  |         this.billingAddress = billingAddress;
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @OneToMany(
  |             mappedBy="client", 
  |             fetch=FetchType.EAGER, 
  |             cascade=CascadeType.ALL)
  |     public Collection<ClientContact> getContacts() {
  |         return(this.contacts);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setContacts(Collection<ClientContact> contacts) {
  |         this.contacts = contacts;
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @Transient
  |     public Contact getPrimaryContact() {
  |         
  |         // see if there is a primary
  |         for (ClientContact contact: this.contacts) {
  |             if (contact.isPrimary()) {
  |                 return(contact);
  |             }
  |         }
  |         
  |         // no primary
  |         return(null);
  |         
  |     }
  | 

This is the ClientContact entity:

  | @Entity
  | @Table(name="tasc_client_contact")
  | @Inheritance
  | public class ClientContact extends ValueObject
  |     implements Contact, Comparable<Contact> {
  |     
  |     private Client client;
  |     private Boolean primary;
  |     private PersonName name;
  |     private PhoneNumber homeNumber;
  |     private PhoneNumber businessNumber;
  |     private PhoneNumber faxNumber;
  |     private PhoneNumber mobileNumber;
  |     private EmailAddress emailAddress;
  |     private Address address;
  | 
  |     /**
  |      * 
  |      */
  |     @ManyToOne(targetEntity=com.tasconline.client.Client.class,
  |                fetch=FetchType.EAGER)
  |     @JoinColumn(name="fk_tasc_client")
  |     public Client getClient() {
  |         return(this.client);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setClient(Client client) {
  |         this.client = client;
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @Column(name="primaryContact")
  |     public Boolean isPrimary() {
  |         return(this.primary);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setPrimary(Boolean primary) {
  |         this.primary = primary;
  |     }
  |     
  |     /**
  |      *
  |      */
  |     @Embedded
  |     public PersonName getName()
  |     {
  |         return(this.name);
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setName(PersonName name)
  |     {
  |         this.name = name;
  |     }
  |     
  |     /**
  |      *
  |      */
  |     @Embedded
  |     @AttributeOverrides({
  |         @AttributeOverride(name="areaCode", [EMAIL 
PROTECTED](name="homeNumberAreaCode")),
  |         @AttributeOverride(name="trunk", [EMAIL 
PROTECTED](name="homeNumberTrunk")),
  |         @AttributeOverride(name="number", [EMAIL 
PROTECTED](name="homeNumberNumber")),
  |         @AttributeOverride(name="extension",[EMAIL 
PROTECTED](name="homeNumberExtension"))
  |     })
  |     public PhoneNumber getHomeNumber()
  |     {
  |         return(this.homeNumber);
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setHomeNumber(PhoneNumber homeNumber)
  |     {
  |         this.homeNumber = homeNumber;   
  |     }
  |     
  |     /**
  |      *
  |      */
  |     @Embedded
  |     @AttributeOverrides({
  |         @AttributeOverride(name="areaCode", [EMAIL 
PROTECTED](name="businessNumberAreaCode")),
  |         @AttributeOverride(name="trunk", [EMAIL 
PROTECTED](name="businessNumberTrunk")),
  |         @AttributeOverride(name="number", [EMAIL 
PROTECTED](name="businessNumberNumber")),
  |         @AttributeOverride(name="extension",[EMAIL 
PROTECTED](name="businessNumberExtension"))
  |     })
  |     public PhoneNumber getBusinessNumber()
  |     {
  |         return(this.businessNumber);
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setBusinessNumber(PhoneNumber businessNumber)
  |     {
  |         this.businessNumber = businessNumber;       
  |     }
  |     
  |     /**
  |      *
  |      */
  |     @Embedded
  |     @AttributeOverrides({
  |         @AttributeOverride(name="areaCode", [EMAIL 
PROTECTED](name="faxNumberAreaCode")),
  |         @AttributeOverride(name="trunk", [EMAIL 
PROTECTED](name="faxNumberTrunk")),
  |         @AttributeOverride(name="number", [EMAIL 
PROTECTED](name="faxNumberNumber")),
  |         @AttributeOverride(name="extension",[EMAIL 
PROTECTED](name="faxNumberExtension"))
  |     })
  |     public PhoneNumber getFaxNumber()
  |     {
  |         return(this.faxNumber);   
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setFaxNumber(PhoneNumber faxNumber)
  |     {
  |         this.faxNumber = faxNumber;   
  |     }
  |     
  |     /**
  |      *
  |      */
  |     @Embedded
  |     @AttributeOverrides({
  |         @AttributeOverride(name="areaCode", [EMAIL 
PROTECTED](name="mobileNumberAreaCode")),
  |         @AttributeOverride(name="trunk", [EMAIL 
PROTECTED](name="mobileNumberTrunk")),
  |         @AttributeOverride(name="number", [EMAIL 
PROTECTED](name="mobileNumberNumber")),
  |         @AttributeOverride(name="extension",[EMAIL 
PROTECTED](name="mobileNumberExtension"))
  |     })
  |     public PhoneNumber getMobileNumber()
  |     {
  |         return(this.mobileNumber);
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setMobileNumber(PhoneNumber mobileNumber)
  |     {
  |         this.mobileNumber = mobileNumber;   
  |     }
  |                                         
  |     /**
  |      *
  |      */
  |     @Embedded
  |     @AttributeOverride(name="address", [EMAIL 
PROTECTED](name="emailAddress"))
  |     public EmailAddress getEmailAddress()
  |     {
  |         return(this.emailAddress);
  |     }
  |     
  |     /**
  |      *
  |      */
  |     public void setEmailAddress(EmailAddress emailAddress)
  |     {
  |         this.emailAddress = emailAddress;    
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     @Embedded
  |     public Address getAddress() {
  |         return(this.address);
  |     }
  |     
  |     /**
  |      * 
  |      */
  |     public void setAddress(Address address) {
  |         this.address = address;
  |     }
  |     
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3911839#3911839

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3911839


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to