- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的项目基于 spring boot、Thymeleaf、mysql、html 和 Jquery。我尝试在 maintable 中创建一个单向的 @oneToMany 关系,但它只产生如下错误
2017-10-23 16:17:49.908 ERROR 18724 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'entityManagerFactory' defined in class path
resource
[org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]:
Invocation of init method failed; nested exception is
org.hibernate.AnnotationException: **Unable to map collection
com.vfraternity.process.entity.EntPropertyMaster.blockListPropSub** at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
~[spring-context-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858)
~[spring-context-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
~[spring-context-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122)
~[spring-boot-2.0.0.M4.jar:2.0.0.M4] at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
[spring-boot-2.0.0.M4.jar:2.0.0.M4] at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
[spring-boot-2.0.0.M4.jar:2.0.0.M4] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
[spring-boot-2.0.0.M4.jar:2.0.0.M4] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)
[spring-boot-2.0.0.M4.jar:2.0.0.M4] at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1233)
[spring-boot-2.0.0.M4.jar:2.0.0.M4] at
com.vfraternity.VfSpringBootMain.main(VfSpringBootMain.java:12)
[classes/:na] Caused by: org.hibernate.AnnotationException: Unable to
map collection
com.vfraternity.process.entity.EntPropertyMaster.blockListPropSub at
org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1604)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:871)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:786)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:725)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1589)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:858)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57)
~[spring-orm-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:358)
~[spring-orm-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:384)
~[spring-orm-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:373)
~[spring-orm-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods AbstractAutowireCapableBeanFactory.java:1761)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698)
~[spring-beans-5.0.0.RC4.jar:5.0.0.RC4] ... 16 common frames omitted
Caused by: org.hibernate.cfg.RecoverableException: Unable to find
column with logical name: propertysubpk in
org.hibernate.mapping.Table(property_master) and its related
supertables and secondary tables at
org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:831)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:243)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] at
org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1594)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] ... 31 common frames
omitted Caused by: org.hibernate.MappingException: Unable to find
column with logical name: propertysubpk in
org.hibernate.mapping.Table(property_master) and its related
supertables and secondary tables at
org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:826)
~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] ... 33 common frames
omitted
我尝试使用单向实现
@OneToMany(cascade=CascadeType.ALL)
@JoinColumn(name="propertysubfkid", referencedColumnName="propertysubpk")
private List<EntPropertySub> blockListPropSub = newArrayList<EntPropertySub>();
但它只产生错误...这是我的完整代码..
**EntPropertyMaster**
package com.vfraternity.process.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
@Entity
@Table(name="Property_Master")
public class EntPropertyMaster implements Serializable{
/**
*
*/
private static final long serialVersionUID = 6162594257264775391L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="propertyid")
private int property_id;
@NotNull
private String property_name;
@NotNull
private String address1;
@NotNull
@Column(columnDefinition="varchar(15) default'None'")
private String address2;
@NotNull
private String city;
@NotNull
private String state;
@NotNull
private String country;
@NotNull
private int zipcode;
@OneToMany(cascade=CascadeType.ALL)
@JoinColumn(name="propertysubfkid", referencedColumnName="propertysubpk")
private List<EntPropertySub> blockListPropSub = new ArrayList<EntPropertySub>();
@Version
private int version;
private Boolean is_active;
private String created_by;
private Date created_ts;
private String modified_by;
private Date modified_ts;
private String approved_by;
private Date approved_ts;
public EntPropertyMaster() {
}
//Getter Setter
public int getProperty_id() {
return property_id;
}
public void setProperty_id(int property_id) {
this.property_id = property_id;
}
public String getProperty_name() {
return property_name;
}
public void setProperty_name(String property_name) {
this.property_name = property_name;
}
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public Boolean getIs_active() {
return is_active;
}
public void setIs_active(Boolean is_active) {
this.is_active = is_active;
}
public String getCreated_by() {
return created_by;
}
public void setCreated_by(String created_by) {
this.created_by = created_by;
}
public Date getCreated_ts() {
return created_ts;
}
public void setCreated_ts(Date created_ts) {
this.created_ts = created_ts;
}
public String getModified_by() {
return modified_by;
}
public void setModified_by(String modified_by) {
this.modified_by = modified_by;
}
public Date getModified_ts() {
return modified_ts;
}
public void setModified_ts(Date modified_ts) {
this.modified_ts = modified_ts;
}
public String getApproved_by() {
return approved_by;
}
public void setApproved_by(String approved_by) {
this.approved_by = approved_by;
}
public Date getApproved_ts() {
return approved_ts;
}
public void setApproved_ts(Date approved_ts) {
this.approved_ts = approved_ts;
}
public int getZipcode() {
return zipcode;
}
public void setZipcode(int zipcode) {
this.zipcode = zipcode;
}
public List<EntPropertySub> getBlockListPropSub() {
return blockListPropSub;
}
public void setBlockListPropSub(List<EntPropertySub> blockListPropSub) {
this.blockListPropSub = blockListPropSub;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////EntPropertySub包 com.vfraternity.process.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
@Entity
@Table(name="propertysub")
public class EntPropertySub implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 810618405796553525L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="propertysubpk")
private int propertySub_pk;
@NotNull
private String blockname;
@NotNull
private int floors;
@NotNull
private String flatstart;
private String flatend;
@Version
private int version;
private Boolean is_active;
private String created_by;
private Date created_ts;
private String modified_by;
private Date modified_ts;
private String approved_by;
private Date approved_ts;
public EntPropertySub() {
}
//Getter Setter
public int getPropertySub_pk() {
return propertySub_pk;
}
public void setPropertySub_pk(int propertySub_pk) {
this.propertySub_pk = propertySub_pk;
}
public String getBlockname() {
return blockname;
}
public void setBlockname(String blockname) {
this.blockname = blockname;
}
public int getFloors() {
return floors;
}
public void setFloors(int floors) {
this.floors = floors;
}
public String getFlatstart() {
return flatstart;
}
public void setFlatstart(String flatstart) {
this.flatstart = flatstart;
}
public String getFlatend() {
return flatend;
}
public void setFlatend(String flatend) {
this.flatend = flatend;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public Boolean getIs_active() {
return is_active;
}
public void setIs_active(Boolean is_active) {
this.is_active = is_active;
}
public String getCreated_by() {
return created_by;
}
public void setCreated_by(String created_by) {
this.created_by = created_by;
}
public Date getCreated_ts() {
return created_ts;
}
public void setCreated_ts(Date created_ts) {
this.created_ts = created_ts;
}
public String getModified_by() {
return modified_by;
}
public void setModified_by(String modified_by) {
this.modified_by = modified_by;
}
public Date getModified_ts() {
return modified_ts;
}
public void setModified_ts(Date modified_ts) {
this.modified_ts = modified_ts;
}
public String getApproved_by() {
return approved_by;
}
public void setApproved_by(String approved_by) {
this.approved_by = approved_by;
}
public Date getApproved_ts() {
return approved_ts;
}
public void setApproved_ts(Date approved_ts) {
this.approved_ts = approved_ts;
}
}
请帮我解决这个问题..提前致谢
最佳答案
错误原因是:
Unable to find column with logical name: propertysubpk in org.hibernate.mapping.Table(property_master)
原因是您的 referencedColumnName
属性错误。应该是:
JPA 2.1 11.1.25: The name of the column referenced by this foreign key column. When used with entity relationship mappings other than the cases described below, the referenced column is in the table of the target entity. When used with a unidirectional OneToMany foreign key mapping, the referenced column is in the table of the source entity. When used inside a Join- Table annotation, the referenced key column is in the entity table of the owning entity, or inverse entity if the join is part of the inverse join definition. When used in a collection table mapping, the referenced column is in the table of the entity containing the collection.
解释一下:@JoinColumn
在关系的many 端(此处为 EntPropertySub
)创建一个列,其给定名称为引用父实体的PK,除非指定referencedColumnName
。在后一种情况下,“many”表中的 FK 引用 referencedColumnName
中给出的列。在您的情况下,您想要引用 EntPropertyMaster
的 PK,因此 referencedColumnName
是多余的。只需使用:
@OneToMany(cascade=CascadeType.ALL)
@JoinColumn(name="propertysubfkid")
private List<EntPropertySub> blockListPropSub = newArrayList<EntPropertySub>();
关于java - 如何使用 JPA 和 Hibernate 为 2 个表建立单向 @oneToMany 关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46887842/
我正在尝试使用 Excel 中的间接函数来构建公式以在另一张纸上返回值。 在工作表 A 单元格 D3 的值为 B 我想使用值 B 从名为 App Summary 的工作表中的单元格 B6 返回一个值。
我目前正在使用 LumiSoft 的 SIP 堆栈,并且能够在我的 FreePBX 盒子上成功注册分机并调用另一个软电话。我现在需要做的就是通过调用流式传输 WAV 文件(或 RAW,或任何可行的文件
这个问题已经有答案了: How can I fix 'android.os.NetworkOnMainThreadException'? (65 个回答) 已关闭 8 年前。 我有一个安卓 Activ
我正在使用 ws npm 在服务器端,websocket 在客户端。 从 node-js 运行此代码时它工作正常,但从浏览器运行它会出现以下错误: failed: Error in connectio
当我将鼠标悬停在想要淡入和淡出的内容上多次时,它就会不断重复。即使我停止悬停它。我怎样才能阻止这个? $(".featured").hover(function(){ $(this).find
我需要建立一个 mysql 连接并取回一些数据。我可以使用此代码在 Java 中执行此操作 try{ String username;
不能制造愚蠢。具有下一个文件夹结构: /flint/double-conversion/src /燧石/愚蠢/愚蠢/ 其中/flint/folly 包含自述文件和许可证。作为in the readme
我想在编译主单元之前在程序集中嵌入本地引用。但书面目标不起作用。 WithMetadataValue( 'CopyLocal', 'true' )->Met
我不是软件专家,但我确实需要一些建议。 我正在编写一个 C 程序(在下面剪切/粘贴)以通过 LAN(以太网)建立从我的 Mac Pro 到位于它旁边的基于 Windows XP 的测试仪器的 TCP
我正在构建一个应用程序,我的手机经常将数据发送到我的服务器。由于我将使用我的移动数据,我想知道建立(和拆除?)到我的服务器的 TCP 连接需要多少数据。 最佳答案 TCP 三向握手 Device 1
我有一个带有登录表单的网站。当加载登录表单页面时,我创建一个新的 PDO 对象以查看连接是否正常工作。如果成功打开连接,查看者将看到一个登录表单。如果不成功,他们会收到一条消息,说明服务器已关闭。 然
构建我的Electron应用程序后,它将显示产品名称undefined。如何设置其他名称呢? 当前是这样的: 最佳答案 请尝试此操作。引用此链接 https://www.electronjs.org/
我有一个项目在哪里使用这个 jar 。 据我所知...发生 war 之后,文件夹WEB-INF/lib必须具有: mail-1.4.1.jar activation-1.1.jar mysql-con
代码: %{ #include #include #include #include "gener.h" #include "sym_tab.h" #include "scope.h" #inc
我需要将侧边栏小部件集成到我的高流量页面(称为SiteA)中。该小部件应包含我的其他页面之一(称为 SiteB)的最新文章。 在我看来,我有两种可能的解决方案。 SiteA 上的 cUrl 调用从 S
我正在尝试建立 Cortana 技能,以便能够使用 Surface 相机拍照。怎么做?目前我的技能是能够使用bot框架和使用nodejs来回答问题。代码看起来像 bot.dialog('ScanCar
这个问题在这里已经有了答案: Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorExce
当我与网络服务器建立 https 连接时出现 SSLProtocolException。我只在 Android 2.3 Gingebread 中有这个异常(exception);相同的代码在所有其他
我想做的是指定几个端口,然后检查它们是否已建立连接。我找到了以下脚本并运行了,但它只列出了 3 个端口,我不明白为什么。我验证了相关端口的事件规则(以及下面输出中未列出的许多其他端口)。 Set ob
使用 MySQL 我试图使用已经上传到数据库中的数据建立一对多关系。举个例子,假设我在一个表中有一个名字列表,我想将它们连接到一个他们去过的地方的列表。显然 1 个人可以去很多不同的地方,但我在设置时
我是一名优秀的程序员,十分优秀!