2011-05-20 56 views
1

我莫名其妙地收到一個「會話已關閉」異常。序列化由Jibernate支持的JPA2實體用於JSON時。JPA實體序列化需要實體管理器,延遲加載不應該是一個問題

如果延遲加載參與,但沒有連接列我能理解。

而且該對象序列化到JSON工具允許包括和排除參數,只需你能明確說明哪些對象的部分會或不會被序列化。如果我手動包含對象的所有屬性,則序列化將起作用。然而,這是非常乏味的,我應該能夠說「objectName。*」並遞歸地序列化。

有意義的唯一的事情就是不知何故對象具有某種它調用休眠實體管理器,但不是在類的可見性的一個屬性?

的後續錯誤是由Struts2的打印輸出:

Struts Problem Report 

Struts has detected an unhandled exception: 
Messages: 

    Session is closed! 
    java.lang.reflect.InvocationTargetException 
    org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException 
    org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException 
    org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException 

File: org/hibernate/impl/AbstractSessionImpl.java 

例外:

org.hibernate.SessionException: Session is closed! 

    org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72) 
    org.hibernate.impl.SessionImpl.getJDBCContext(SessionImpl.java:2000) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    java.lang.reflect.Method.invoke(Method.java:597) 
    org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:234) 
    org.apache.struts2.json.JSONWriter.process(JSONWriter.java:164) 
    org.apache.struts2.json.JSONWriter.value(JSONWriter.java:130) 
    org.apache.struts2.json.JSONWriter.add(JSONWriter.java:336) 
    org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:235) 
    org.apache.struts2.json.JSONWriter.process(JSONWriter.java:164) 
    org.apache.struts2.json.JSONWriter.value(JSONWriter.java:130) 
    org.apache.struts2.json.JSONWriter.add(JSONWriter.java:336) 
    org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:235) 
    org.apache.struts2.json.JSONWriter.process(JSONWriter.java:164) 
    org.apache.struts2.json.JSONWriter.value(JSONWriter.java:130) 
    org.apache.struts2.json.JSONWriter.add(JSONWriter.java:336) 
    org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:235) 
    org.apache.struts2.json.JSONWriter.process(JSONWriter.java:164) 
    org.apache.struts2.json.JSONWriter.value(JSONWriter.java:130) 
    org.apache.struts2.json.JSONWriter.write(JSONWriter.java:98) 
    org.apache.struts2.json.JSONUtil.serialize(JSONUtil.java:112) 
    org.apache.struts2.json.JSONResult.execute(JSONResult.java:198) 
    com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277) 
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) 
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) 
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) 
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) 
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) 
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166) 
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) 
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) 
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) 
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485) 
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) 
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) 
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215) 
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) 
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
    org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) 
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 
    com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) 
    com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) 
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) 
    org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) 
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) 
    com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) 
    com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) 
    com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) 
    com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) 
    com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) 
    com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
    com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
    com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
    com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
    com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
    com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
    com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
    com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
    java.lang.Thread.run(Thread.java:619) 

這裏是實體:

/* 
* To change this template, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package com.aerose.mz.db.co05in; 

import java.io.Serializable; 
import java.util.Date; 
import javax.persistence.Basic; 
import javax.persistence.Column; 
import javax.persistence.EmbeddedId; 
import javax.persistence.Entity; 
import javax.persistence.NamedQueries; 
import javax.persistence.NamedQuery; 
import javax.persistence.Table; 
import javax.persistence.Temporal; 
import javax.persistence.TemporalType; 
import javax.validation.constraints.NotNull; 
import javax.validation.constraints.Size; 
import javax.xml.bind.annotation.XmlRootElement; 

/** 
* 
* @author ken 
*/ 
@Entity 
@Table(name = "INTBLMST") 
@XmlRootElement 
@NamedQueries({ 
    @NamedQuery(name = "Intblmst.findAll", query = "SELECT i FROM Intblmst i"), 
    @NamedQuery(name = "Intblmst.findByTblid", query = "SELECT i FROM Intblmst i WHERE i.intblmstPK.tblid = :tblid"), 
    @NamedQuery(name = "Intblmst.findByTblcd", query = "SELECT i FROM Intblmst i WHERE i.intblmstPK.tblcd = :tblcd"), 
    @NamedQuery(name = "Intblmst.findByTblsta", query = "SELECT i FROM Intblmst i WHERE i.tblsta = :tblsta"), 
    @NamedQuery(name = "Intblmst.findByTblds1", query = "SELECT i FROM Intblmst i WHERE i.tblds1 = :tblds1"), 
    @NamedQuery(name = "Intblmst.findByTblds2", query = "SELECT i FROM Intblmst i WHERE i.tblds2 = :tblds2"), 
    @NamedQuery(name = "Intblmst.findByTblamt", query = "SELECT i FROM Intblmst i WHERE i.tblamt = :tblamt"), 
    @NamedQuery(name = "Intblmst.findByTblfg1", query = "SELECT i FROM Intblmst i WHERE i.tblfg1 = :tblfg1"), 
    @NamedQuery(name = "Intblmst.findByTblfg2", query = "SELECT i FROM Intblmst i WHERE i.tblfg2 = :tblfg2"), 
    @NamedQuery(name = "Intblmst.findByTblfg3", query = "SELECT i FROM Intblmst i WHERE i.tblfg3 = :tblfg3"), 
    @NamedQuery(name = "Intblmst.findByTblecn", query = "SELECT i FROM Intblmst i WHERE i.tblecn = :tblecn"), 
    @NamedQuery(name = "Intblmst.findByTbledt", query = "SELECT i FROM Intblmst i WHERE i.tbledt = :tbledt"), 
    @NamedQuery(name = "Intblmst.findByTblacn", query = "SELECT i FROM Intblmst i WHERE i.tblacn = :tblacn"), 
    @NamedQuery(name = "Intblmst.findByTbladt", query = "SELECT i FROM Intblmst i WHERE i.tbladt = :tbladt"), 
    @NamedQuery(name = "Intblmst.findByTblaus", query = "SELECT i FROM Intblmst i WHERE i.tblaus = :tblaus"), 
    @NamedQuery(name = "Intblmst.findByTblmcn", query = "SELECT i FROM Intblmst i WHERE i.tblmcn = :tblmcn"), 
    @NamedQuery(name = "Intblmst.findByTblmdt", query = "SELECT i FROM Intblmst i WHERE i.tblmdt = :tblmdt"), 
    @NamedQuery(name = "Intblmst.findByTblmus", query = "SELECT i FROM Intblmst i WHERE i.tblmus = :tblmus"), 
    @NamedQuery(name = "Intblmst.findByAdded", query = "SELECT i FROM Intblmst i WHERE i.added = :added"), 
    @NamedQuery(name = "Intblmst.findByModified", query = "SELECT i FROM Intblmst i WHERE i.modified = :modified")}) 
public class Intblmst implements Serializable { 
    private static final long serialVersionUID = 1L; 
    @EmbeddedId 
    protected IntblmstPK intblmstPK; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLSTA", nullable = false) 
    private char tblsta; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 60) 
    @Column(name = "TBLDS1", nullable = false, length = 60) 
    private String tblds1; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 25) 
    @Column(name = "TBLDS2", nullable = false, length = 25) 
    private String tblds2; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLAMT", nullable = false) 
    private long tblamt; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLFG1", nullable = false) 
    @Size(max = 1) 
    private String tblfg1; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 5) 
    @Column(name = "TBLFG2", nullable = false, length = 5) 
    private String tblfg2; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 10) 
    @Column(name = "TBLFG3", nullable = false, length = 10) 
    private String tblfg3; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLECN", nullable = false) 
    private long tblecn; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLEDT", nullable = false) 
    private long tbledt; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLACN", nullable = false) 
    private long tblacn; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLADT", nullable = false) 
    private long tbladt; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 10) 
    @Column(name = "TBLAUS", nullable = false, length = 10) 
    private String tblaus; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLMCN", nullable = false) 
    private long tblmcn; 
    @Basic(optional = false) 
    @NotNull 
    @Column(name = "TBLMDT", nullable = false) 
    private long tblmdt; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 10) 
    @Column(name = "TBLMUS", nullable = false, length = 10) 
    private String tblmus; 
    @Column(name = "Added") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date added; 
    @Column(name = "Modified") 
    @Temporal(TemporalType.TIMESTAMP) 
    private Date modified; 

    public Intblmst() { 
    } 

    public Intblmst(IntblmstPK intblmstPK) { 
     this.intblmstPK = intblmstPK; 
    } 

    public Intblmst(IntblmstPK intblmstPK, char tblsta, String tblds1, String tblds2, long tblamt, String tblfg1, String tblfg2, String tblfg3, long tblecn, long tbledt, long tblacn, long tbladt, String tblaus, long tblmcn, long tblmdt, String tblmus) { 
     this.intblmstPK = intblmstPK; 
     this.tblsta = tblsta; 
     this.tblds1 = tblds1; 
     this.tblds2 = tblds2; 
     this.tblamt = tblamt; 
     this.tblfg1 = tblfg1; 
     this.tblfg2 = tblfg2; 
     this.tblfg3 = tblfg3; 
     this.tblecn = tblecn; 
     this.tbledt = tbledt; 
     this.tblacn = tblacn; 
     this.tbladt = tbladt; 
     this.tblaus = tblaus; 
     this.tblmcn = tblmcn; 
     this.tblmdt = tblmdt; 
     this.tblmus = tblmus; 
    } 

    public Intblmst(String tblid, String tblcd) { 
     this.intblmstPK = new IntblmstPK(tblid, tblcd); 
    } 

    public IntblmstPK getIntblmstPK() { 
     return intblmstPK; 
    } 

    public void setIntblmstPK(IntblmstPK intblmstPK) { 
     this.intblmstPK = intblmstPK; 
    } 

    public char getTblsta() { 
     return tblsta; 
    } 

    public void setTblsta(char tblsta) { 
     this.tblsta = tblsta; 
    } 

    public String getTblds1() { 
     return tblds1; 
    } 

    public void setTblds1(String tblds1) { 
     this.tblds1 = tblds1; 
    } 

    public String getTblds2() { 
     return tblds2; 
    } 

    public void setTblds2(String tblds2) { 
     this.tblds2 = tblds2; 
    } 

    public long getTblamt() { 
     return tblamt; 
    } 

    public void setTblamt(long tblamt) { 
     this.tblamt = tblamt; 
    } 

    public String getTblfg1() { 
     return tblfg1; 
    } 

    public void setTblfg1(String tblfg1) { 
     this.tblfg1 = tblfg1; 
    } 

    public String getTblfg2() { 
     return tblfg2; 
    } 

    public void setTblfg2(String tblfg2) { 
     this.tblfg2 = tblfg2; 
    } 

    public String getTblfg3() { 
     return tblfg3; 
    } 

    public void setTblfg3(String tblfg3) { 
     this.tblfg3 = tblfg3; 
    } 

    public long getTblecn() { 
     return tblecn; 
    } 

    public void setTblecn(long tblecn) { 
     this.tblecn = tblecn; 
    } 

    public long getTbledt() { 
     return tbledt; 
    } 

    public void setTbledt(long tbledt) { 
     this.tbledt = tbledt; 
    } 

    public long getTblacn() { 
     return tblacn; 
    } 

    public void setTblacn(long tblacn) { 
     this.tblacn = tblacn; 
    } 

    public long getTbladt() { 
     return tbladt; 
    } 

    public void setTbladt(long tbladt) { 
     this.tbladt = tbladt; 
    } 

    public String getTblaus() { 
     return tblaus; 
    } 

    public void setTblaus(String tblaus) { 
     this.tblaus = tblaus; 
    } 

    public long getTblmcn() { 
     return tblmcn; 
    } 

    public void setTblmcn(long tblmcn) { 
     this.tblmcn = tblmcn; 
    } 

    public long getTblmdt() { 
     return tblmdt; 
    } 

    public void setTblmdt(long tblmdt) { 
     this.tblmdt = tblmdt; 
    } 

    public String getTblmus() { 
     return tblmus; 
    } 

    public void setTblmus(String tblmus) { 
     this.tblmus = tblmus; 
    } 

    public Date getAdded() { 
     return added; 
    } 

    public void setAdded(Date added) { 
     this.added = added; 
    } 

    public Date getModified() { 
     return modified; 
    } 

    public void setModified(Date modified) { 
     this.modified = modified; 
    } 

    @Override 
    public int hashCode() { 
     int hash = 0; 
     hash += (intblmstPK != null ? intblmstPK.hashCode() : 0); 
     return hash; 
    } 

    @Override 
    public boolean equals(Object object) { 
     // TODO: Warning - this method won't work in the case the id fields are not set 
     if (!(object instanceof Intblmst)) { 
      return false; 
     } 
     Intblmst other = (Intblmst) object; 
     if ((this.intblmstPK == null && other.intblmstPK != null) || (this.intblmstPK != null && !this.intblmstPK.equals(other.intblmstPK))) { 
      return false; 
     } 
     return true; 
    } 

    @Override 
    public String toString() { 
     return "com.aerose.mz.db.co05in.Intblmst[ intblmstPK=" + intblmstPK + " ]"; 
    } 

} 

這裏是嵌入式ID:

/* 
* To change this template, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package com.aerose.mz.db.co05in; 

import java.io.Serializable; 
import javax.persistence.Basic; 
import javax.persistence.Column; 
import javax.persistence.Embeddable; 
import javax.validation.constraints.NotNull; 
import javax.validation.constraints.Size; 

/** 
* 
* @author ken 
*/ 
@Embeddable 
public class IntblmstPK implements Serializable { 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 5) 
    @Column(name = "TBLID", nullable = false, length = 5) 
    private String tblid; 
    @Basic(optional = false) 
    @NotNull 
    @Size(min = 1, max = 8) 
    @Column(name = "TBLCD", nullable = false, length = 8) 
    private String tblcd; 

    public IntblmstPK() { 
    } 

    public IntblmstPK(String tblid, String tblcd) { 
     this.tblid = tblid; 
     this.tblcd = tblcd; 
    } 

    public String getTblid() { 
     return tblid; 
    } 

    public void setTblid(String tblid) { 
     this.tblid = tblid; 
    } 

    public String getTblcd() { 
     return tblcd; 
    } 

    public void setTblcd(String tblcd) { 
     this.tblcd = tblcd; 
    } 

    @Override 
    public int hashCode() { 
     int hash = 0; 
     hash += (tblid != null ? tblid.hashCode() : 0); 
     hash += (tblcd != null ? tblcd.hashCode() : 0); 
     return hash; 
    } 

    @Override 
    public boolean equals(Object object) { 
     // TODO: Warning - this method won't work in the case the id fields are not set 
     if (!(object instanceof IntblmstPK)) { 
      return false; 
     } 
     IntblmstPK other = (IntblmstPK) object; 
     if ((this.tblid == null && other.tblid != null) || (this.tblid != null && !this.tblid.equals(other.tblid))) { 
      return false; 
     } 
     if ((this.tblcd == null && other.tblcd != null) || (this.tblcd != null && !this.tblcd.equals(other.tblcd))) { 
      return false; 
     } 
     return true; 
    } 

    @Override 
    public String toString() { 
     return "com.aerose.mz.db.co05in.IntblmstPK[ tblid=" + tblid + ", tblcd=" + tblcd + " ]"; 
    } 

} 

回答

3

它看起來像JSON序列遇到lazy proxy並嘗試序列與調用HibernateProxy.getHibernateLazyInitializer()獲得其延遲初始化處理程序。您可以嘗試將您的JSON序列化程序配置爲忽略該方法。

+0

我不明白。如果我明確列出所有的公共getter(這是所有的序列化程序應該工作,它按預期工作)。我不知道我在這裏選擇吸管,我已經啓用了字節代碼工具,它應該不會對我的課程做任何事情嗎?不應該只有懶惰的代理,如果它試圖加入一些東西? – Quaternion 2011-05-20 22:24:39

+0

@ Quaternion:我不確定你的情況究竟發生了什麼。你可以在實際的序列化對象類中找出它們中的哪一個是代理。 – axtavt 2011-05-22 10:08:09

+0

我認爲它是與字節碼儀表,當我使用反射顯示的實體的內容,有一個吸氣劑爲「fieldHandler」返回:FieldInterceptorImpl(=的entityName com.aerose.mz.db.co05in。 Insalmst,髒=假,uninitializedFields = NULL)。 (目前我正在處理與上面不同的實體,但我認爲問題是在讀取該屬性時觸發的。)因此,指定此屬性不被序列化時,如果有其他人遇到問題,則應解決該問題。 – Quaternion 2011-05-25 17:44:42