Dec 17, 2015 3:49:03 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [spring] in context with path [/crafartweb] threw exception [Request processing failed; nested
异常是org.hibernate.HibernateException:有多行 找到给定的标识符:681,用于类: 具有根本原因的com.crafart.dataobjects.StoreDO] org.hibernate.HibernateException:找到了多个具有给定标识符的行:681,用于类:com.crafart.dataobjects.StoreDO 在org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:104) 在org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:161) 在org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2374) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:722) 在org.hibernate.type.EntityType.resolve(EntityType.java:492) 在org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:168) 在org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137) 在org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1112) 在org.hibernate.loader.Loader.processResultSet(Loader.java:969) 在org.hibernate.loader.Loader.doQuery(Loader.java:917) 在org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348) 在org.hibernate.loader.Loader.doList(Loader.java:2548) 在org.hibernate.loader.Loader.doList(Loader.java:2534) 在org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2364) 在org.hibernate.loader.Loader.list(Loader.java:2359) 在org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:495) 在org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:357) 在org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) 在org.hibernate.internal.SessionImpl.list(SessionImpl.java:1194) 在org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) 在com.crafart.data.SellerDAOImpl.getSellerDetails(SellerDAOImpl.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在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) at org.springframework.transaction.interceptor.TransactionInterceptor $ 1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 在org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 在org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 在com.sun.proxy。$ Proxy78.getSellerDetails(未知来源) 在com.crafart.seller.service.ManageSellerServiceImpl.getSellerDetails(ManageSellerServiceImpl.java:170) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在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) at org.springframework.transaction.interceptor.TransactionInterceptor $ 1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 在org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 在org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 在com.sun.proxy。$ Proxy89.getSellerDetails(未知来源) 在com.crafart.MenuController.showManageSellers(MenuController.java:216) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) 在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) 在org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) 在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) 在org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:620) 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421) 在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:316) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run (Thread.java:744)
My StoreClass is ---
/**
*
*/
package com.crafart.dataobjects;
import java.io.Serializable;
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.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
* store entity data object maps to store table in crafart database. Property
* belongs to store table and store_id is primary key which is generated by db
* sequence <blockquote>seq_store<blockquote>
*
* @author Karthi
* @version 1.0
*
*/
@Entity
@Table(name = "STORE")
public class StoreDO implements Serializable, Cloneable {
/**
*
*/
private static final long serialVersionUID = -3168290124126749175L;
@Id
@Column(name = "store_id")
@SequenceGenerator(name = "seq_store", sequenceName = "seq_store", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_store")
private long storeId;
@ManyToOne
@JoinColumn(name = "seller_id", nullable = false)
private SellerDO sellerDO;
@Column(name = "name")
private String name;
@Column(name = "store_url")
private String storeUrl;
@Column(name = "store_description")
private String storeDescription;
@Column(name = "return")
private String storeReturn;
public SellerDO getSellerDO() {
return sellerDO;
}
public void setSellerDO(SellerDO sellerDO) {
this.sellerDO = sellerDO;
}
public long getStoreId() {
return storeId;
}
public void setStoreId(long storeId) {
this.storeId = storeId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStoreUrl() {
return storeUrl;
}
public void setStoreUrl(String storeUrl) {
this.storeUrl = storeUrl;
}
public String getStoreDescription() {
return storeDescription;
}
public void setStoreDescription(String store_Description) {
this.storeDescription = store_Description;
}
public String getStoreReturn() {
return storeReturn;
}
public void setStoreReturn(String store_Return) {
this.storeReturn = store_Return;
}
}
**
storeBO class is this
**
/**
*
*/
package com.crafart.dataobjects;
import java.io.Serializable;
import java.util.ArrayList;
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.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
/**
* seller entity data object maps to seller table in crafart database. Property
* belongs to seller table and seller_id is primary key which is generated by db
* sequence <blockquote>seq_seller<blockquote>
*
* @author karthi
* @version 1.0
*/
@Entity
@Table(name = "SELLER")
public class SellerDO implements Serializable, Cloneable {
/**
* generated serial id
*/
private static final long serialVersionUID = 2950842206999695829L;
@Id
@Column(name = "seller_id")
@SequenceGenerator(name = "seq_seller", sequenceName = "seq_seller", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_seller")
private long sellerId;
@OneToMany(mappedBy = "sellerDO", targetEntity=StoreDO.class, cascade = CascadeType.ALL)
private StoreDO storeDO;
@Column(name = "first_Name")
private String firstName;
@ManyToMany(cascade = { CascadeType.ALL })
@JoinTable(name = "SELLER_ADDRESS", joinColumns = { @JoinColumn(name = "SELLER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ADDRESS_ID") })
private List<AddressDO> addressDOs = new ArrayList<>();
@OneToMany(cascade = { CascadeType.ALL })
@JoinTable(name = "SELLER_CONTACT", joinColumns = { @JoinColumn(name = "SELLER_ID") }, inverseJoinColumns = { @JoinColumn(name = "CONTACT_ID") })
private List<ContactDO> contactDOs = new ArrayList<>();
@ManyToMany(mappedBy = "sellerDOs")
private List<ProductDO> productDOs = new ArrayList<>();
@Column(name = "last_Name")
private String lastName;
@Column(name = "gender")
private int gender;
@Column(name = "dob")
private String dateOfBirth;
private int tin_no;
@Column(name = "company_Name")
private String companyName;
@Column(name = "company_Logo")
private String companyLogo;
@Column(name = "epch_no")
private String epchNo;
@Column(name = "vat_no")
private String vat_no;
@Column(name = "cst_no")
private String cst_no;
/*
* add variables
* */
@Column(name = "gst_no")
private String gst_no;
@Column(name = "officeno")
private int officeno;
@Column(name = "mobileno")
private int mobileno;
@Column(name = "email")
private String email;
@Column(name = "panno")
private String panno;
@OneToOne(cascade = {CascadeType.ALL})
@JoinColumn(name = "commission_id",nullable = true)
private CommissionDO commissionDO;
private int status;
private int approved;
@Column(name = "password")
private String password;
@Column(name = "confirm_password")
private String confirmpassword;
public String getEpchNo() {
return epchNo;
}
public void setEpchNo(String epchNo) {
this.epchNo = epchNo;
}
public String getConfirmpassword() {
return confirmpassword;
}
public void setConfirmpassword(String confirmpassword) {
this.confirmpassword = confirmpassword;
}
public long getSellerId() {
return sellerId;
}
public void setSellerId(long sellerId) {
this.sellerId = sellerId;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getTin_no() {
return tin_no;
}
public void setTin_no(int tin_no) {
this.tin_no = tin_no;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getCompanyLogo() {
return companyLogo;
}
public void setCompanyLogo(String companyLogo) {
this.companyLogo = companyLogo;
}
public String getEpch_no() {
return epchNo;
}
public void setEpch_no(String epch_no) {
this.epchNo = epch_no;
}
public String getVat_no() {
return vat_no;
}
public int getOfficeno() {
return officeno;
}
public void setOfficeno(int officeno) {
this.officeno = officeno;
}
public int getMobileno() {
return mobileno;
}
public void setMobileno(int mobileno) {
this.mobileno = mobileno;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPanno() {
return panno;
}
public void setPanno(String panno) {
this.panno = panno;
}
public void setVat_no(String vat_no) {
this.vat_no = vat_no;
}
public String getCst_no() {
return cst_no;
}
public void setCst_no(String cst_no) {
this.cst_no = cst_no;
}
public String getGst_no() {
return gst_no;
}
public void setGst_no(String gst_no) {
this.gst_no = gst_no;
}
public CommissionDO getCommissionDO() {
return commissionDO;
}
public void setCommissionDO(CommissionDO commissionDO) {
this.commissionDO = commissionDO;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getApproved() {
return approved;
}
public void setApproved(int approved) {
this.approved = approved;
}
public String getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(String dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public int getGender() {
return gender;
}
public void setGender(int gender) {
this.gender = gender;
}
public List<ContactDO> getContactDOs() {
return contactDOs;
}
public void setContactDOs(List<ContactDO> contactDOs) {
this.contactDOs = contactDOs;
}
public StoreDO getStoreDO() {
return storeDO;
}
public void setStoreDO(StoreDO storeDO) {
this.storeDO = storeDO;
}
public List<AddressDO> getAddressDOs() {
return addressDOs;
}
public void setAddressDOs(List<AddressDO> addressDOs) {
this.addressDOs = addressDOs;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<ProductDO> getProductDOs() {
return productDOs;
}
public void setProductDOs(List<ProductDO> productDOs) {
this.productDOs = productDOs;
}
}
答案 0 :(得分:0)
您的映射无效
@OneToMany(mappedBy = "sellerDO", targetEntity=StoreDO.class, cascade = CascadeType.ALL)
private StoreDO storeDO;
应该是
@OneToMany(mappedBy = "sellerDO", targetEntity=StoreDO.class, cascade = CascadeType.ALL)
private List<StoreDO> storeDO;
@OneToMany(mappedBy = "sellerDO", targetEntity=StoreDO.class, cascade = CascadeType.ALL)
private Set<StoreDO> storeDO;