英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论