Broadleaf:扩展产品实体失败

时间:2017-11-21 05:26:42

标签: broadleaf-commerce

您好我已经扩展了Broadleaf产品实体并为该实体添加了一个新属性,并添加了管理员演示文稿注释以显示在管理员端

这是我的代码扩展实体:

@AdminPresentationMergeOverrides({@AdminPresentationMergeOverride(name = "ExtendProductImpl.productWarranty", mergeEntries = {@AdminPresentationMergeEntry(propertyType = PropertyType.AdminPresentation.EXCLUDED, booleanOverrideValue=false)})})
public class ExtendProductImpl extends ProductImpl implements ExtendProduct {

@Column(name ="PRODUCT_WARRANTY")
@AdminPresentation(friendlyName = "product warrenty",
tab = TabName.General)

private String productWarranty;

 public String getProductWarranty() {

return productWarranty;

}



public void setProductWarranty(String productWarranty) {

this.productWarranty = productWarranty;

}}

这是我在Core中的XML文件(ApplicationContextEntity.xml):

http://i.prntscr.com/u2UjARtwRVmI-PswDzxErw.png

这是另一个XML文件(Persistant-core):

http://i.prntscr.com/9Z8y_SplQNKp7HjCw4XyiA.png

以下是应用更改后的输出屏幕截图:

http://i.prntscr.com/Gv-ssCaSTa2QbbS5rLB2vg.png

http://i.prntscr.com/eGWugVJRQ-aQqS_heWHsxw.png

请帮我解决这个问题。

提前致谢

1 个答案:

答案 0 :(得分:1)

您需要再做一件事,并将演示产品更新为扩展类型。问题是,如果您仍然依赖于演示数据,Hibernate仍会将其视为ProductImpl而不是ExtendProductImpl

在您的代码段中,您还没有@javax.persistence.Entity@javax.persistence.Table注释。此外,通常不需要为自定义域对象创建接口,它是可选的。所以假设它实际上是这样的:

@Entity
@Table(name = "ext_product")
@AdminPresentationMergeOverrides({@AdminPresentationMergeOverride(name = "ExtendProductImpl.productWarranty", mergeEntries = {@AdminPresentationMergeEntry(propertyType = PropertyType.AdminPresentation.EXCLUDED, booleanOverrideValue=false)})})

public class ExtendProductImpl extends ProductImpl实现ExtendProduct {

然后,您应该通过将数据插入子类来将演示数据更新为ExtendProductImpl类型:

INSERT INTO ext_product (PRODUCT_ID) (SELECT PRODUCT_ID FROM BLC_PRODUCT)

最后,您可能还希望确保无论何时在管理员中创建产品,它都应始终为ExtendProductImpl类型。为此,请使用@AdminPresentationClass

@Entity
@Table(name = "ext_product")
@AdminPresentationClass(ceilingDisplayEntity = "com.mycompany.ExtendProductImpl")
@AdminPresentationMergeOverrides({@AdminPresentationMergeOverride(name = "ExtendProductImpl.productWarranty", mergeEntries = {@AdminPresentationMergeEntry(propertyType = PropertyType.AdminPresentation.EXCLUDED, booleanOverrideValue=false)})})
public class ExtendProductImpl extends ProductImpl implements ExtendProduct {