- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个 Spring-MVC 应用程序,其中我使用 hibernate 作为 ORM 工具,使用 PostgreSQL 作为数据库。目前,当我通过几种方法从数据库访问数据时遇到问题。一直以来,错误都是一样的。我没有坚持任何东西,而只是请求数据。
对于 3-4 个 DAO 方法,问题总是发生在 getUniqueResult 处。你能帮忙的话,我会很高兴。另外,我检查了答案,但他们只给出了一些场景,它们都不适用,因为我只是查询数据。
错误代码:
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.HibernateException: Found shared references to a collection: com.journaldev.spring.model.Person.canvas1
org.hibernate.HibernateException: Found shared references to a collection: com.journaldev.spring.model.Person.canvas1
com.journaldev.spring.dao.GroupAttachmentsDAOImpl.returnAttachmentCount(GroupAttachmentsDAOImpl.java:108)
有问题的代码:
@Override
public int returnAttachmentCount(int mnoticesid) {
session = this.sessionFactory.getCurrentSession();
Query query = session.createQuery("select count(*) from GroupAttachments as a where a.mnotedata.mnoticesid=:mnoticesid");
query.setParameter("mnoticesid",mnoticesid);
return Integer.valueOf(String.valueOf(query.uniqueResult()));
}
任何帮助都会很好。多谢。 :-)
编辑
人物映射:
@OneToMany(mappedBy = "person1",fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
@Index(name = "canvas1index")
private Set<Canvas> canvas1 = new HashSet<Canvas>();
public Set<Canvas> getCanvas1() {
return canvas1;
}
public void setCanvas1(Set<Canvas> canvas1) {
this.canvas1 = canvas1;
}
@OneToMany(mappedBy = "userConversation",fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
private Set<Conversation> conversations = new HashSet<Conversation>();
public Set<Conversation> getConversations(){
return this.conversations;
}
public void setConversations(Set<Conversation> conversations){
this.conversations=conversations;
}
@OneToMany(mappedBy = "user1Conversation",fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
private Set<Conversation> conversation1 = new HashSet<>();
public Set<Conversation> getConversation1(){
return this.conversation1;
}
public void setConversation1(Set<Conversation> conversation1){
this.conversation1=conversation1;
}
@OneToMany(mappedBy = "replyingPerson",fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
@Index(name = "replyingpersonindex")
private Set<Replies> repliesSet = new HashSet<>();
public Set<Replies> getRepliesSet(){
return this.repliesSet;
}
public void setRepliesSet(Set<Replies> repliesSet){
this.repliesSet = repliesSet;
}
@OneToMany(mappedBy = "personStatistics",fetch = FetchType.LAZY,cascade = CascadeType.REMOVE)
private Set<Statistics> statisticsSet = new HashSet<>();
public Set<Statistics> getStatisticsSet(){
return this.statisticsSet;
}
public void setStatisticsSet(Set<Statistics> statisticsSet){
this.statisticsSet = statisticsSet;
}
以上都是Person映射
Canvas 映射:
@ManyToOne
@JoinColumn(name = "id",nullable = false)
@JsonIgnore
@Index(name = "person1")
private Person person1;
public Person getPerson1() {
return person1;
}
public void setPerson1(Person person1) {
this.person1 = person1;
}
public int getPerson1id(){
return this.person1.getId();
}
@OneToMany(mappedBy = "canvas2",fetch=FetchType.LAZY, cascade = CascadeType.REMOVE)
@JsonIgnore
@Index(name = "section2")
private Set<Section> section2 = new HashSet<Section>();
public Set<Section> getSection2() {
return section2;
}
public void setSection2(Set<Section> section2) {
this.section2 = section2;
}
这些都是映射,并且完全没有像我描述的那样与 GroupAttachments 相关联。
编辑
完整的堆栈跟踪:
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.HibernateException: Found shared references to a collection: com.journaldev.spring.model.Person.canvas1
type Exception report
message Request processing failed; nested exception is org.hibernate.HibernateException: Found shared references to a collection: com.journaldev.spring.model.Person.canvas1
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.HibernateException: Found shared references to a collection: com.journaldev.spring.model.Person.canvas1
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1179)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
root cause
org.hibernate.HibernateException: Found shared references to a collection: com.journaldev.spring.model.Person.canvas1
org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:180)
org.hibernate.event.internal.FlushVisitor.processCollection(FlushVisitor.java:59)
org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:121)
org.hibernate.event.internal.AbstractVisitor.processValue(AbstractVisitor.java:82)
org.hibernate.event.internal.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:76)
org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:172)
org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231)
org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102)
org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:61)
org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1191)
org.hibernate.internal.SessionImpl.list(SessionImpl.java:1257)
org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
org.hibernate.internal.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:966)
com.journaldev.spring.dao.GroupAttachmentsDAOImpl.returnAttachmentCount(GroupAttachmentsDAOImpl.java:108)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy104.returnAttachmentCount(Unknown Source)
com.journaldev.spring.service.GroupAttachmentsServiceImpl.returnAttachmentCount(GroupAttachmentsServiceImpl.java:228)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy94.returnAttachmentCount(Unknown Source)
com.journaldev.spring.dao.GroupNotesDAOImpl.listGroupNotesBySectionId(GroupNotesDAOImpl.java:137)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy109.listGroupNotesBySectionId(Unknown Source)
com.journaldev.spring.service.GroupNotesServiceImpl.listGroupNotesBySectionId(GroupNotesServiceImpl.java:495)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
com.sun.proxy.$Proxy90.listGroupNotesBySectionId(Unknown Source)
com.journaldev.spring.controller.PersonController.listNotes(PersonController.java:1442)
com.journaldev.spring.controller.PersonController$$FastClassBySpringCGLIB$$f2c66d65.invoke(<generated>)
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:640)
com.journaldev.spring.controller.PersonController$$EnhancerBySpringCGLIB$$4fd054fd_2.listNotes(<generated>)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1179)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
列表注释方法:
@Override
public List<Notes> listNotesBySectionId(int sectionid) {
session = this.sessionFactory.getCurrentSession();
Query query = session.createQuery("from Notes as n where n.section1.sectionid=:sectionid and n.noteDisabled=false and n.noteInActive=false order by n.noteorder");
query.setParameter("sectionid", sectionid);
List<Notes> notesList = query.list();
if(notesList.isEmpty()){
return notesList;
} else {
double i = 1.0;
for (Notes notes : notesList) {
notes.setNoteorder(i);
notes.setNotetext(notes.getNotetext().replaceAll("\\r?\\n", "<br/>"));
notes.setNotetag(notes.getNotetag().replaceAll("\\r?\\n", "<br/>"));
i = i + 1;
notes.setAttachCount(this.attachmentService.returnAttachmentCount(notes.getNoticesid()));
}
return notesList;
}
}
Also returnAttachmentCount()
@Override
public int returnAttachmentCount(int noticesid) {
session = this.sessionFactory.getCurrentSession();
Query query = session.createQuery("select count(*) from Attachment as a where a.notedata.noticesid=:noticesid");
query.setParameter("noticesid",noticesid);
return new Integer(String.valueOf(query.uniqueResult()));
}
最佳答案
这是一个反复出现的问题,您可以在建议的解决方案中看到类似的问题 here .基本上,您是将同一个集合实例分配给多个实体实例。
为什么在查询中会出现这种情况?好吧,您没有发布整个堆栈跟踪。在那里我们可能会看到异常实际上是在查询执行前自动刷新期间在脏检查时抛出的——它与这个特定的查询(或 getUniqueResult 方法)无关。
重新检查如何在一对多映射中为 Person.canvas1 分配值(以及其他可能获得对“已使用”集合实例的相同引用的实体)。经验法则是(伪代码):
entity.collection = new ArrayList(otherCollectionInstance);
或
entity.collection = new ArrayList();
entity.collection.addAll(otherCollectionInstance)
或(在更新已持久化(托管)实体实例的情况下)
entity.collection.clear();
entity.collection.addAll(otherCollectionInstance)
这就是为什么使用字段初始化来将对多关联初始化为空集合是一个很好的约定:
@Entity
public class MyEntity {
@OneToMany(...)
private Collection<MyAssociatedEntity> = new ArrayList<>();
}
编辑
发生这种情况似乎还有一些其他原因,其中一些描述了 here .
在这方面,我看到了您的 Canvas 实体的奇怪映射:
@ManyToOne
@JoinColumn(name = "id",nullable = false)
@JsonIgnore
@Index(name = "person1")
private Person person1;
join 列是否应该是“PERSON_ID”之类的其他内容?
关于java - Spring MVC, hibernate : Found shared references to collection when retreiving data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30372161/
我正在对 Share 开发和执行一些自定义。我的 IDE 是 Eclipse Juno,工作区由以下元素组成: 露天网络项目 扩展 Java 项目 分享网站项目 alfresco 和 share we
这是我一直面临的一个非常奇怪的问题。我正在使用 Share.share,它将消息、主题 (ios) 和标题(对于 gmail)作为参数。在android中它工作正常。即主题行是“我是标题”,而消息正文
当在static上下文中未使用而不是时(也就是说,当static关键字不存在并且您不在全局范围内时),shared和__gshared关键字有什么作用? 例子: struct Temp {
我想知道如何从 Surf 中的 Root 对象知道当前主机名。 我正在编写一个服务于 JNLP 的网络脚本,所以我没有页面上下文,并且 ${url.context} 只返回 /share。 我正在寻找
我想知道如何从 Surf 中的 Root 对象知道当前主机名。 我正在编写一个服务于 JNLP 的网络脚本,所以我没有页面上下文,并且 ${url.context} 只返回 /share。 我正在寻找
我需要在 Alfresco Share 上下文中创建一个无需身份验证即可访问的页面。使用页面框架时,它看起来非常简单,因为您可以添加 none到页面定义。 当使用 aikau 时,页面定义消失了,我只
我有执行REST命令并处理结果的python脚本。我希望该脚本可被不同的Jenkins Pipelines使用,我通过Jenkins官方文档发现的一种方式是使用“共享库”,而这些示例(以及我在网上找到
查看此函数(矩阵 vector 积): std::vector times(std::vector > const& A, std::vector const& b, int m, int n) {
我正在尝试弄清楚如何与 Alfresco Share 执行一些 dashlet 间通信。 这是一个简单的用例: 我们确实有 2 个 dashlet,我们称它们为 A 和 B。我希望能够在 A 中填写字
是否可以在 Snowflake 的 FUNCTION 或 PROCEDURE 中发出“Show Shares”函数调用?由于信息架构中没有元数据对象来查询有关共享的信息,因此我们正在寻找一种方法来创建
我对“无共享”分布式系统的理解是集群中的每个节点都有自己的磁盘可以持久化。如果是这种情况,我不确定为什么拥有这样的架构会有好处,因为您不仅需要在应用程序级别进行复制/负载平衡/集群,而且还需要在磁盘上
我对“无共享”分布式系统的理解是集群中的每个节点都有自己的磁盘可以持久化。如果是这种情况,我不确定为什么拥有这样的架构会有好处,因为您不仅需要在应用程序级别进行复制/负载平衡/集群,而且还需要在磁盘上
在 Alfresco 4.0 中,我想扩展 Share Doclib Filter webscript 以添加我自己的自定义过滤器。 有没有一种简单的方法可以在 share-config-custom
假设我要匹配: PREFIXsomething 或: somethingPOSTFIX 但肯定不是: PREFIXsomethingPOSTFIX 其中 something 是某种共享模式,而 PRE
我正在寻找一种使用 JavaScript 在 google drive sdk 上查找用户共享文件列表的方法。 重要提示:我不是在寻找“与我共享”的文件列表。 我目前所拥有的列出了“与我共享”的文件,
最近刚开始使用 swifting,在使用应用程序组在 iOS 设备之间共享数据时遇到了问题。 基本上我已经按照以下步骤设置了项目: [iPhone] 为 iPhone 目标启用应用程序组 初始化数据如
我知道 -Wl,-shared 是 ld 的一个选项。我见过有人这样编译, $ gcc -shared -Wl,-soname,libtest.so -o libtest.so *.o 还有这样的人
我想知道对这句名言最接地气的解释是什么: Don't communicate by sharing memory; share memory by communicating. (R. Pike) 在
我不确定我在这里做错了什么,我认为应该有更多的文档或关于这个Web Share API的更好的错误描述。。我正在尝试共享以下文件。使用。我已经确保该类型是允许的类型,但我一直收到DOMExceptio
我正在研究 RxSwift 和 RxCocoa。官方文档中有这些解释。 分享副作用 分享资源 它们是一样的吗?如果有区别,那有什么区别?光看官方文档的解释,我看不懂。 预先感谢您的回答。 最佳答案 文
我是一名优秀的程序员,十分优秀!