Quarkus 3 + Hibernate 6 包错误

huangapple go评论59阅读模式
英文:

Quarkus 3 + Hibernate 6 error on packages

问题

我将翻译以下部分:

我将我的项目升级到了Quarkus 3,但我遇到了这个错误

关联 'com.step.trackactions.model.PlatformActionLeadEntity.company' 目标未知实体名 'com.step.common.model.Company'


`PlatformActionLeadEntity` 像这样定义

@Entity
@Table(name = "PlatformAction")
@RegisterForReflection
public class PlatformActionLeadEntity{

private Customer customer;

private Company company;

}


而且 Company 和 Customer 都被标记为实体

@Entity
@MappedSuperclass
@Table(name = "Company")
@RegisterForReflection
public class Company extends PanacheEntityBase implements Cloneable { ... }


@Entity
@MappedSuperclass
@Table(name = "Customer")
@RegisterForReflection
public class Customer extends PanacheEntityBase implements Cloneable { ... }


关键问题是
* `com.step.trackactions.model.PlatformActionLeadEntity` 在项目内
* `com.step.common.model.Company` 在项目中导入的外部库中

并且在 `application.properties` 中我添加了

quarkus.hibernate-orm.packages=com.step


但它不起作用,旧版本的 quarkus 他曾经工作过 :(

<details>
<summary>英文:</summary>

I updated my Project to Quarkus 3 and I am getting this error

Association 'com.step.trackactions.model.PlatformActionLeadEntity.company' targets an unknown entity named 'com.step.common.model.Company'


`PlatformActionLeadEntity` is made like this

@Entity
@Table(name = "PlatformAction")
@RegisterForReflection
public class PlatformActionLeadEntity{

private Customer customer;

private Company company;

}


and both Company and Customer are tagged as entity

@Entity
@MappedSuperclass
@Table(name = "Company")
@RegisterForReflection
public class Company extends PanacheEntityBase implements Cloneable { ... }


@Entity
@MappedSuperclass
@Table(name = "Customer")
@RegisterForReflection
public class Customer extends PanacheEntityBase implements Cloneable { ... }


the point is that
* `com.step.trackactions.model.PlatformActionLeadEntity` is inside the project 
* `com.step.common.model.Company` is in an external library imported in the project

and in `application.properties` I added

quarkus.hibernate-orm.packages=com.step


but it dies not work, with the old version of quarkus he used to work :(

</details>


# 答案1
**得分**: 0

我找到了问题,问题出在注解`@MappedSuperclass`上。你不能同时给一个类注解`@Entity`和`@MappedSuperclass`。

<details>
<summary>英文:</summary>

I found the problem, it is the annotation `@MappedSuperclass`. You cannot annotate a class with `@Entity` and `@MappedSuperclass`

</details>



huangapple
  • 本文由 发表于 2023年5月29日 22:30:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76358189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定