您好我的表格如下:
1- medical_company :
2- account_entity :
3 人同行:
4- employee_company:
实体:
1- 医疗公司:
@SuppressWarnings("serial")
@Entity
@Table(name = "medical_company")
public class MedicalCompany implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
@Basic(fetch = FetchType.EAGER)
private Long id;
@OneToOne
@Cascade(value = { CascadeType.ALL })
@JoinColumn(name = "medical_company_id", referencedColumnName = "account_entity_id")
private AccountEntity accountEntity;
}
2- AccountEntity:
@SuppressWarnings("serial")
@Entity
@Table(name = "account_entity")
public class AccountEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "account_entity_id", unique = true, nullable = false)
@Basic(fetch = FetchType.EAGER)
private Long id;
}
3 人同行
@SuppressWarnings("serial")
@Entity
@Table(name = "person")
public class Person implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "person_id", unique = true, nullable = false)
@Basic(fetch = FetchType.EAGER)
private Long id;
}
4- EmployeeCompanyId :
@SuppressWarnings("serial")
@Embeddable
public class EmployeeCompanyId implements Serializable {
@ManyToOne
private Person person;
@ManyToOne
private MedicalCompany medicalCompany;
@Size(max = 150, message = "{long.value}")
@Column(name = "title_text", length = 150, nullable = true)
private String titleText;
@Column(name = "employee_manager")
private long employeeManager;
}
5- 员工公司:
@SuppressWarnings("serial")
@Entity
@Table(name = "employee_company")
@AssociationOverrides(value = {
@AssociationOverride(name = "pk.medicalCompany", joinColumns = @JoinColumn(referencedColumnName = "medical_company_id")),
@AssociationOverride(name = "pk.person", joinColumns = @JoinColumn(referencedColumnName = "person_id")),
@AssociationOverride(name = "pk.titleText"),
@AssociationOverride(name = "pk.employeeManager") })
public class EmployeeCompany implements Serializable {
@EmbeddedId
private EmployeeCompanyId pk = new EmployeeCompanyId();
@Transient
public void setEmployeeManager(long employeeManager) {
this.pk.setEmployeeManager(employeeManager);
}
public long getEmployeeManager() {
return pk.getEmployeeManager();
}
@Transient
public void setTitleText(String titleText) {
this.pk.setTitleText(titleText);
}
public String getTitleText() {
return pk.getTitleText();
}
public void setPerson(Person person) {
this.pk.setPerson(person);
}
@Transient
public Person getPerson() {
return this.pk.getPerson();
}
public void setMedicalCompany(MedicalCompany medicalCompany) {
this.pk.setMedicalCompany(medicalCompany);
}
@Transient
public MedicalCompany getMedicalCompany() {
return this.pk.getMedicalCompany();
}
public void setPk(EmployeeCompanyId pk) {
this.pk = pk;
}
public EmployeeCompanyId getPk() {
return pk;
}
}
尝试运行应用程序时,出现以下错误:
org.hibernate.MappingException: Unable to find column with logical name: medical_company_id in org.hibernate.mapping.Table(medical_company) and its related supertables and secondary tables
at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:550)
at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:126)
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:110)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:520)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:380)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1206)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:717)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
请告知为什么我收到此错误,以及如何解决它。
此错误告诉您在medical_company表上没有名为medical_company_id的列。medical_company上的列仅称为id。
问题内容: 我有5个表,每个表与下一个表有一对多的关系 。project_t-> project_level1_t-> project_level2_t-> project_level3_t-> project_level4_t 我想让用户hibernate这些表 和project_level1_t 和project_level2_t 这是存储库文件 和 和 但是当我运行我的应用程序时,出现此错误
有两个表。酒店内的地址。我已经提到了OneTo很多关系。但是编译器抛出错误。 创建名为entityManagerFactory的bean时出错,该bean在类路径资源[org/springFramework/boot/autoconfiure/orm/jpa/HibernateJpaConfiguration.class]中定义:调用init方法失败;嵌套异常org.hibernate.Mappi
currency_pair的DDL 我的实体类如下:- 货币实体- 注意:我无法更改ddl查询,那么我可以做什么来修复实体类
我的服务类 和我的控制器类:
我有这个实体,它的ID定义在可识别类。 InventoryLoad的主键为InventoryLoadID 这是上述类的ID 我正在使用Criteria builder访问ID类的列。 要使用 Path 来获取此信息以获取 PK 的库存 ID 的路径。 获取此错误
所以我有这个kotlin项目: 获取此异常: 有一个小型演示项目:https://github.com/TomGrill/spring-hibernate-bug 应要求: