- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人可以解释一下,这实际上应该如何实现吗?
我有一个父实体(在底部堆栈跟踪中称为 Executor):
class Parent {
@Id
private int id;
}
我有一个子项(堆栈跟踪中的 Param1CK,params3 表),其 Id 是复合的,并且依赖于“父项”和“行号”:
@IdClass(ChildID.class)
class Child {
@Id
@ManyToOne
@JoinColumn
private Parent parent;
@Id
@Column
private int id;
}
class ChildID implements Serializable{
private Parent parent;
private int id;
@Override
public int hashCode() {...}
}
parent中Child的集合描述为:
@OneToMany(mappedBy="parent")
@Cascasde(value = CascadeType.ALL)
private List<Child> list = ...;
这一点似乎没有得到正确的解决。
当我尝试做:
Parent p = new Parent();
p.getList().add(new Child(p)); // with the Parent targeting in the constructor
并且执行多次“保存”操作,Hibernate无法解析 key ,并执行一个循环来解析父 key ,即解析为stackOverFlow:
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
Hibernate: select executor0_.id as id1_3_1_, executor0_.parent_id as parent_i2_3_1_, params3x1_.parent_id as parent_i3_6_3_, params3x1_.prop as prop1_6_3_, params3x1_.prop as prop1_6_0_, params3x1_.parent_id as parent_i3_6_0_, params3x1_.value as value2_6_0_ from executor executor0_ left outer join paraaaamsssck params3x1_ on executor0_.id=params3x1_.parent_id where executor0_.id=?
2019-04-19 11:05:19 WARN [localhost-startStop-1] AnnotationConfigServletWebServerApplicationContext.refresh: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fixingTheSessionCrapService': Invocation of init method failed; nested exception is java.lang.StackOverflowError
2019-04-19 11:05:19 INFO [localhost-startStop-1] ExecutorService.killRunningSessions: Killing any running sessions
2019-04-19 11:05:19 INFO [localhost-startStop-1] ExecutorService.killRunningSessions: Done. ATA closed gracefully
2019-04-19 11:05:19 INFO [localhost-startStop-1] ThreadPoolTaskExecutor.shutdown: Shutting down ExecutorService 'getDaemonThreadPool'
2019-04-19 11:05:19 INFO [localhost-startStop-1] LocalContainerEntityManagerFactoryBean.destroy: Closing JPA EntityManagerFactory for persistence unit 'default'
2019-04-19 11:05:19 INFO [localhost-startStop-1] HikariDataSource.close: HikariPool-1 - Shutdown initiated...
2019-04-19 11:05:19 INFO [localhost-startStop-1] HikariDataSource.close: HikariPool-1 - Shutdown completed.
2019-04-19 11:05:19 INFO [localhost-startStop-1] ConditionEvaluationReportLoggingListener.logMessage:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-04-19 11:05:19 ERROR [localhost-startStop-1] SpringApplication.reportFailure: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fixingTheSessionCrapService': Invocation of init method failed; nested exception is java.lang.StackOverflowError
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:139)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:157)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:137)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:91)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.StackOverflowError: null
at java.base/java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:578)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:292)
at java.base/sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:281)
at java.base/sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
at java.base/java.io.OutputStreamWriter.write(OutputStreamWriter.java:211)
at java.base/java.io.BufferedWriter.flushBuffer(BufferedWriter.java:120)
at java.base/java.io.PrintStream.write(PrintStream.java:526)
at java.base/java.io.PrintStream.print(PrintStream.java:666)
at java.base/java.io.PrintStream.println(PrintStream.java:803)
at org.apache.tomcat.util.log.SystemLogHandler.println(SystemLogHandler.java:267)
at org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:96)
at org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:78)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:167)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1984)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1914)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1892)
at org.hibernate.loader.Loader.doQuery(Loader.java:937)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:340)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:310)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2281)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:64)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:54)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4271)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:511)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:481)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:222)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:124)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1256)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1139)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:682)
at org.hibernate.type.EntityType.resolve(EntityType.java:464)
at org.hibernate.type.ManyToOneType.resolve(ManyToOneType.java:239)
at org.hibernate.type.EntityType.resolve(EntityType.java:457)
at org.hibernate.type.ComponentType.resolve(ComponentType.java:688)
at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:862)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:718)
at org.hibernate.loader.Loader.processResultSet(Loader.java:990)
at org.hibernate.loader.Loader.doQuery(Loader.java:948)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:340)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:310)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2281)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:64)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:54)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4271)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:511)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:481)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:222)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:124)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
这会持续很长的循环,直到出现 StackOverflow 异常。最后指出:
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1256)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1139)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:682)
at org.hibernate.type.EntityType.resolve(EntityType.java:464)
at org.hibernate.type.ManyToOneType.resolve(ManyToOneType.java:239)
最佳答案
1) 让你的 id 类可嵌入,因为你有一个 ManyToOne 关系作为 id 的一部分:
@Embeddable
class ChildID implements Serializable{
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "parent_id")
private Parent parent;
private int id;
2) 更改 Child
类:
@Entity
class Child {
@EmbeddedId
private ChildID id;
3) 更改父实体上的 mappedBy
以考虑嵌入关系:
@OneToMany(mappedBy="id.parent")
@Cascasde(value = CascadeType.ALL)
private List<Child> list = ...;
关于java - Spring Boot 。复合键和级联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55758647/
我正在实现一个显示容器级别的图表。根据填充水平,线条的颜色应该改变(例如,接近最大值时应该显示红色)。我不想计算线条的不同部分并手动设置它们的颜色,而是想定义一个颜色自动改变的带。我想用自定义 Com
#include int main(void) { int days, hours, mins; float a, b, c, total, temp, tempA, tempB; a
if()//first if { if()//second if statement; } else statement; 我知道 else 与第一个 if 匹配,但我的问题是为什么?我是
以下代码中测试了 Ready 的哪个实例,为什么? interface type TObject1 = class ... public property Ready: boole
我刚刚花了相当多的时间来寻找像这个 plunk 中的差距.问题没那么简单。这是一个动态创建的页面,一些具有 margin-bottom 的组件恰好显示在 .main 的最后。 在我指责 CSS 之前,
我的程序应该在对话中创建圆形图标。我有三个按钮,每个按钮代表要制作的图标的颜色。因此,如果我点击不同的按钮 10 次,我的程序应该创建 10 个不同颜色的圆圈。这是我的代码,分为 2 个类: impo
我读过; A compound literal is a C99 feature that can be used to create an array with no name. Consider
当您创建一个复合 View 并为其扩充 xml 布局文件时,如下所示: public class CompundLayout extends LinearLayout{...} 这会像这样用根扩展一个
我正在创建一个带有标签和文本框的复合 uibinder 小部件。 预期用途是: The text to be put in the box. 我找到了如何使用自定义 @UiConstruc
任何人都可以举一个结合使用设计模式组合和责任链的实际例子吗? 谢谢 最佳答案 一个非常实际的例子是 GUI 设计,例如 Qt 框架。 QObject 可以是单个对象或多个对象的组合。 QObjects
我在这个项目中的一些表单中使用了复合 View 模型的模式。它工作得很好。 在这种情况下,我有一个 VendorAddress View 模型。我在这个项目的几个地方使用了 Address(es),所
我正在尝试构建一个我认为需要多个 JOIN 的 SQL 查询,但我不知道语法。 这是每个表(带有列名)的粗略示例。 T1( key ,名称) T2(键,fkeyT1) T3(键,fkeyT2) 我想从
我有一个 Composite我希望能够以编程方式启用/禁用。 Control.setEnabled(boolean enabled)方法工作正常,但它没有提供任何小部件被禁用的视觉信息。 我想做的是让
如果子域不是“mobile”并且文件名不是“design”或“photo”,我想回显某些内容,因此 echo if (not“mobile”且不是“design”)或(not“mobile”而不是“照
我有一张有几列的 table 。第 1 列和第 2 列可以包含四个 alpha 值中的任何一个:set={A,B,C,D}。 我想检查每列是否包含集合中的两个值之一。所以我想简化这个陈述: SELEC
我创建了一个全局数据类型,并在页面中使用表单渲染器让用户填写数据并提交到网站。 默认的英语工作正常。现在,当我尝试支持第二种语言时,我遇到了问题。根据复合文档: 1.在 ~/Frontend/Comp
我需要将自定义对象作为值存储在字典中,例如具有两个复合整数键的 datastrukturer。 (复合 ID) 我尝试使用数组作为键,但两者都不起作用,因为我猜这只是指向该数组的指针,用作键 如果我能
版本:3.2.1 关系 表B中的两列与表A中的两列相关联。 表A-> hasMany->表B 表B->属于--表A B.a_id = A.a_id B.a_name = A.a_name 食谱 在食谱
我创建了一个全局数据类型,并在页面中使用表单渲染器让用户填写数据并提交到网站。 默认的英语工作正常。现在,当我尝试支持第二种语言时,我遇到了问题。根据复合文档: 1.在 ~/Frontend/Comp
当前版本的 Log4net 是否有办法创建具有复合滚动样式的 RollingFileAppender,其中滚动文件始终保留给定的扩展名(在我的情况下为 .log)? 我想要的格式示例: MyLog.l
我是一名优秀的程序员,十分优秀!