2015-12-17 87 views
-2
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 at 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) at 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) at org.hibernate.loader.Loader.processResultSet(Loader.java:969) at org.hibernate.loader.Loader.doQuery(Loader.java:917) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348) at org.hibernate.loader.Loader.doList(Loader.java:2548) at org.hibernate.loader.Loader.doList(Loader.java:2534) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader。 java:2364) at org.hibernate.loader.Loader.list(Loader.java:2359) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:495) at org.hibernate.hql。 internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:357) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195) at org.hibernate.internal.SessionImpl.list(SessionImpl。的java:1194) 在org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) 在com.crafart.data.SellerDAOImpl.getSellerDetails(SellerDAOImpl.java:82) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang中.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) at 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:99) 在org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) 在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。在org.springframework.aop處的java.lang.reflect.Method.invoke(Method.java:606) 處調用(NativeMethodAccessorImpl.java:57) (在DelegatingMethodAccessorImpl.java:43) 。 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:99) 在org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) 在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) 在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.M ethod.invoke(Method.java:606) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at 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:8 5) 在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) at 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) 在有機.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:170) at 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) 在org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.ja VA:615) 在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run (Thread.java:744)org.hibernate.HibernateException:多個行具有給定標識符發現:681

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

您有一個無效的映射

@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; 
相關問題