Page 1 of 1

Can't get entending customer form order.getCustomer

Posted: Mon Dec 01, 2014 4:31 am
by johnson.yu
hi,

I have extended a customer with new field named "message", the entity class named "OwnerCustomerImpl", then I can see the value of message is stored into DB when I created a new customer. After this customer created a order, then I want to get the customer from order like "order.getCustomer()", and I want to get the "message" value, so I just costed this customer like
"OwnerCustomerImpl customer= (OwnerCustomerImpl)order.getCustomer()" ,

but I got cost error.

I debugged the code, and I can see the type of "order.getCustomer()" is "CustomerImpl", not as expected "OwnerCustomerImpl".

So should I do some extra work for this problem? I read the DOC about this, but it seems I need not do any other things, so can anybody help to take a look this problem?

thanks
Johnson

Re: Can't get entending customer form order.getCustomer

Posted: Tue Dec 02, 2014 7:43 pm
by phillipuniverse
Make sure that you have this in applicationContext-entity.xml:

Code: Select all

<bean id="org.broadleafcommerce.profile.core.domain.Customer" class="com.yourcompany.OwnerCustomerImpl" scope="prototype" />

Re: Can't get entending customer form order.getCustomer

Posted: Wed Dec 03, 2014 4:38 am
by johnson.yu
hi phillipuniverse ,

I can sure the following is in applicationContent-entity.xml:

Code: Select all

 <bean id="org.broadleafcommerce.profile.core.domain.Customer" class="com.mycompany.model.customer.OwnerCustomerImpl" scope="prototype"/>


Actually, I think this extending entity is worked for some feature, because when I register a new customer, I can see the message value is stored in DB.

So is there some other reason for this problem?

thanks
Johnson

Re: Can't get entending customer form order.getCustomer

Posted: Wed Dec 03, 2014 10:56 am
by phillipuniverse
Look in the database and see if you have entries in BLC_CUSTOMER that are not in OWNER_CUSTOMER. If you are in a development environment, is it possible that you have entries in BLC_CUSTOMER prior to you making that entity override?