Quarkus 3 + Hibernate 6 包错误

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

Quarkus 3 + Hibernate 6 error on packages

问题

我将翻译以下部分:

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

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

  1. `PlatformActionLeadEntity` 像这样定义

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

  1. private Customer customer;
  2. private Company company;

}

  1. 而且 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 { ... }

  1. 关键问题是
  2. * `com.step.trackactions.model.PlatformActionLeadEntity` 在项目内
  3. * `com.step.common.model.Company` 在项目中导入的外部库中
  4. 并且在 `application.properties` 中我添加了

quarkus.hibernate-orm.packages=com.step

  1. 但它不起作用,旧版本的 quarkus 他曾经工作过 :(
  2. <details>
  3. <summary>英文:</summary>
  4. 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'

  1. `PlatformActionLeadEntity` is made like this

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

  1. private Customer customer;
  2. private Company company;

}

  1. 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 { ... }

  1. the point is that
  2. * `com.step.trackactions.model.PlatformActionLeadEntity` is inside the project
  3. * `com.step.common.model.Company` is in an external library imported in the project
  4. and in `application.properties` I added

quarkus.hibernate-orm.packages=com.step

  1. but it dies not work, with the old version of quarkus he used to work :(
  2. </details>
  3. # 答案1
  4. **得分**: 0
  5. 我找到了问题,问题出在注解`@MappedSuperclass`上。你不能同时给一个类注解`@Entity``@MappedSuperclass`
  6. <details>
  7. <summary>英文:</summary>
  8. I found the problem, it is the annotation `@MappedSuperclass`. You cannot annotate a class with `@Entity` and `@MappedSuperclass`
  9. </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:

确定