I just extend CustomerImpl with a new field nameed message, But I got error after commands: mvn clean, install and ant jetty-demo, like:
Code: Select all
ERROR (org.springframework.web.context.ContextLoader:331)- Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in resource loaded from byte array: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: blPU] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
...
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: blPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
...
Caused by: org.hibernate.AnnotationException: Foreign key circularity dependency involving the following tables:
at org.hibernate.cfg.Configuration.buildRecursiveOrderedFkSecondPasses(Configuration.java:1488)
The following are my changes:
1. Create a new class to implement CustomerImpl:
Code: Select all
@Entity
@EntityListeners(value = { AuditableListener.class, CustomerPersistedEntityListener.class })
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "BLC_CUSTOMER")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "blCustomerElements")
@AdminPresentationClass(populateToOneFields = PopulateToOneFieldsEnum.TRUE, friendlyName = "CustomerImpl_baseCustomer")
@DirectCopyTransform({
@DirectCopyTransformMember(templateTokens = DirectCopyTransformTypes.PREVIEW, skipOverlaps=true),
@DirectCopyTransformMember(templateTokens = DirectCopyTransformTypes.MULTITENANT_SITE)
})
public class OwnerCustomerImpl extends CustomerImpl{
@Column(name = "MESSAGE")
protected String message;
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
2. Added the entity in \DemoSite\core\src\main\resources\META-INF\persistence-core.xml like:
Code: Select all
<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/web</non-jta-data-source>
[b]<class>com.mycompany.model.customer.OwnerCustomerImpl</class>[/b]
<exclude-unlisted-classes/>
</persistence-unit>
3. Add bean in \DemoSite\core\src\main\resources\applicationContext-entity.xml like:
Code: Select all
<bean id="org.broadleafcommerce.profile.core.domain.Customer" class="com.mycompany.model.customer.OwnerCustomerImpl" scope="prototye"/>
that's all my steps, so can someone help me to fix the issue?
Many thanks
Johnson