Page 1 of 1

Unmapped JPA entity Error while extending existing Entitry

Posted: Thu Jun 19, 2014 9:59 am
by adarshkkumar
Hi,

Im trying to extend ProductImpl , in the extended class if I want to use say

List<Product> someProduct = new ArrayList<Product>;
Im getting the following exception
Use of @OneToMany or @ManyToMany targeting an unmapped class

I'm stuck with this for long time.
I saw this package org.broadleafcommerce.common.extensibility.jpa.clone and annotation interfaces within them, do i need to use any of them if i want to use the polymorphic version of the ProductObject in the extented class?
or am I wrong with the whole idea of using interface here ?

Re: Unmapped JPA entity Error while extending existing Entitry

Posted: Thu Jun 19, 2014 11:00 am
by phillipuniverse
Use the targetEntity property in the JPA annotations. This is required when targeting interfaces.

Here is how the List<Sku> is annotated on ProductImpl:

Code: Select all

@OneToMany(fetch FetchType.LAZYtargetEntity SkuImpl.class, mappedBy="product")
protected List<
SkuadditionalSkus = new ArrayList<Sku>();
 

Re: Unmapped JPA entity Error while extending existing Entitry

Posted: Thu Jun 19, 2014 11:03 am
by phillipuniverse
Also, you do not have to target the subclassed version of ProductImpl in your targetEntity; Hibernate will inject the correct version (ProductImpl or MyProductImpl) appropriately.

Re: Unmapped JPA entity Error while extending existing Entitry

Posted: Fri Jun 20, 2014 3:40 am
by adarshkkumar
hey thanks @phillipuniverse it seems to work but, since im using a field in subclassed version in mappedBy im getting following exception.

mappedBy reference an unknown target entity property: org.broadleafcommerce.core.catalog.domain.ProductImpl.stores
where as stores is in MyProdcutImpl.java

Re: Unmapped JPA entity Error while extending existing Entitry

Posted: Fri Jun 20, 2014 10:27 am
by phillipuniverse
If you are mapping to a property from a subclass, then yes, you need to target the subclass itself (MyProductImpl.class).

Re: Unmapped JPA entity Error while extending existing Entitry

Posted: Fri Jun 20, 2014 11:03 am
by adarshkkumar
thanks @phillipuniverse for the clarifications,It was very helpful.

Re: Unmapped JPA entity Error while extending existing Entitry

Posted: Wed Apr 22, 2015 1:38 am
by rihmjihm
I am getting ClassNotFoundException for my custom entity which I created in the core module. I have listed that class in the blPu persistence unit as well as added it to the applicationContext.xml in the core module of the site by defining