集成第三方框架中的jpa

一个第三方的框架,内部已经定义好实体模型,也写好了增删改查逻辑,但是没有@JmixEntity这样的注解,有没有什么方式使其能够被复用呢,直接集成会使用会报错

 No [EntityType] was found for the key class [org.dromara.warm.flow.orm.entity.FlowDefinition] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>org.dromara.warm.flow.orm.entity.FlowDefinition</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.

   api 'org.dromara.warm:warm-flow-jpa-sb3-starter:1.6.6'
    api 'org.dromara.warm:warm-flow-plugin-ui-sb-web:1.6.6'

这个错是出现在什么阶段?

查询数据的阶段

我试了试,确实有点问题,涉及到 Jmix 底层的 JPA 部分,英文论坛提了个帖子:https://forum.jmix.io/t/integrate-3rd-party-entities/6352 要是有进展我就贴过来。

1 个赞

Unfortunately external entities cannot be used in Jmix directly in compiled form, because the entities must be enhanced to be used in Jmix mechanisms.

Perhaps the easiest way to integrate external models is to write a separate layer of entities and mappers as we do when consuming external APIs, see Integrating Applications Using OpenAPI: Creating Entities and Mappers.

BTW, another obstacle in this particular model is that the entity is annotated with Lombok’s @Data, which generates incorrect equals/hashCode methods and will break Jmix behavior in some cases.

Regards,
Konstantin

基于上面第二段,我感觉你可以用这个第三方包里的 DAO 操作数据,然后用 mapper 转成 Jmix 可以使用的 DTO。