阔叶:扩展产品实体失败 [英] Broadleaf: extending product entity failed

查看:96
本文介绍了阔叶:扩展产品实体失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



这是我的代码扩展实体:

  @AdminPresentationMergeOverrides({@ AdminPresentationMergeOverride(name = ExtendProductImpl.productWarranty,mergeEntries = {@AdminPresentationMergeEntry( propertyType = PropertyType.AdminPresentation.EXCLUDED,booleanOverrideValue = false)}}})
公共类ExtendProductImpl扩展了ProductImpl实现的ExtendProduct {

@Column(name = PRODUCT_WARRANTY)
@ AdminPresentation(friendlyName =产品保修,
选项卡= TabName.General)

私有字符串productWarranty;

public String getProductWarranty(){

return productWarranty;

}



public void setProductWarranty(String productWarranty){

this.productWarranty = productWarranty;

}}

这是我在Core(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件事,并将演示产品更新为扩展型产品。问题是,如果您仍然依赖演示数据,则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,booleanOverridec = false)})})$ b $ c <$ / pre>

公共类ExtendProductImpl扩展ProductImpl实现ExtendProduct {



然后应将演示数据全部更新为通过将数据插入子类来对 ExtendProductImpl 类型进行修改:

  INSERT INTO ext_product (PRODUCT_ID)(从BLC_PRODUCT中选择PRODUCT_ID)

最后,您可能还希望确保每次创建时管理员中的产品,其类型应始终为 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)})}))
公共类ExtendProductImpl扩展了ProductImpl实现的ExtendProduct {


Hi I Have extended the Broadleaf Product Entity and added a new attribute to that Entity and added the admin presentation annotation to display on the admin side

Here Is My Code to Extend the entity:

@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;

}}

Here Is my XML files in Core (ApplicationContextEntity.xml) :

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

Here is the another XML file (Persistant-core) :

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

Here is the output Screen shot after applying the changes:

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

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

Please help me to solve the issue.

Thanks In Advance

解决方案

You need to do 1 more thing and update the demo products to all be of your extended type. The problem is that if you are still relying on the demo data, Hibernate will still treat them as ProductImpl and not as ExtendProductImpl.

In your code snippet, you also do not have a @javax.persistence.Entity or @javax.persistence.Table annotations. Also, there is generally no need to create an interface for your custom domain object, it is optional. So assuming that it is actually this:

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

public class ExtendProductImpl extends ProductImpl implements ExtendProduct {

You should then update the demo data to all be of ExtendProductImpl type by inserting data into the subclass:

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

Finally, you might also want to ensure that whenever you create a product in the admin, it should always be of type ExtendProductImpl. To do this, use @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 {

这篇关于阔叶:扩展产品实体失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆