关于StandardEntity类和应用程序组件的相关问题

我参考这个帖子 如何创建类似StandardEntity的问题?
建立了一个实体,以这个实体替代StandardEntity进行使用,在本项目中继承或是将项目打包成应用程序组件,继承这个实体,就会报错,提示父类的字段未找到,请问是否有办法实现这样的效果?

12:01:04.407 ERROR c.h.c.c.s.AbstractWebAppContextLoader   - Error initializing application
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [order] failed. Close all factories for this PersistenceUnit.
Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-60] (Eclipse Persistence Services - 2.7.3.6-cuba): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_set_group_vh] or [_persistence_get_group_vh] is not defined in the object [com.company.order.entity.Order].
Internal Exception: java.lang.NoSuchMethodException: com.company.order.entity.Order._persistence_get_group_vh()
Mapping: org.eclipse.persistence.mappings.ManyToOneMapping[group]
Descriptor: RelationalDescriptor(com.company.order.entity.Order --> [DatabaseTable(ORDER_ORDER)])

从异常看,好像你get方法没加吧

1赞

但确实是加了的
我上传了一个Demo
Demo中,Bill为参照StandardEntity,Bill1为继承StandardEntity,子类继承后,Test报错,Test1不报错,打包为组件以后,Order和Order1也是一样

而且在切换父类的过程中,IDE生成的update脚本经常出错,导致Duplicate column name 'ID’这样的错误

Project.rar (730.1 KB)

本项目继承的问题已解决,只要父类不写在entity目录下即可,但是封装成组件后继承问题仍未解决

Project1.rar (748.1 KB)