-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Help me ,hiberante throws WARN : On CollectionLoadCon
PostPosted: Fri Aug 22, 2008 12:43 am 
Newbie

Joined: Tue Mar 11, 2008 4:23 am
Posts: 8
Parent class
Code:
package com.morepower.domain.report;

import java.io.Serializable;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToOne;
import javax.persistence.Transient;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.Max;
import org.hibernate.validator.Min;

import com.morepower.domain.Department;
import com.morepower.util.Tools;

/**
* 产品月快报
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "REPORTER_TYPE", discriminatorType = DiscriminatorType.STRING, length = 80)
@DiscriminatorValue("ReporterTTP")
public class AbstractReporter implements Serializable {
   
   protected final Log log = LogFactory.getLog(this.getClass());

   private String id;

   private String title;

   private java.util.Calendar timestamp;

   private String unitLeader;

   private String reportMaker;

   private String reportMakerLocalName;

   private Department unitName;

   private String unitCode;

   private ContactInfomation contact;

   private String remark;

   private Float increateRate = 0.0f;

   private Double lastCulumateValue = 0d;
   
   private String dateString = "0000-00-00";

   public AbstractReporter(){}
   
   /**
    * @return remark
    */
   public String getRemark() {
      return remark;
   }

   /**
    * @param remark
    *            the remark to set
    */
   public void setRemark(String remark) {
      this.remark = remark;
   }

   /**
    * @return 联系方式
    */
   @OneToOne
   public ContactInfomation getContact() {
      return contact;
   }

   /**
    * @param contact
    *            the contact to set
    */
   public void setContact(ContactInfomation contact) {
      this.contact = contact;
   }

   /**
    * @return 单位代码
    */
   public String getUnitCode() {
      return unitCode;
   }

   /**
    * @param unitCode
    *            the unitCode to set
    */
   public void setUnitCode(String unitCode) {
      this.unitCode = unitCode;
   }

   /**
    * 系统id
    */
   @Id
   @GeneratedValue(generator = "system-uuid")
   @GenericGenerator(name = "system-uuid", strategy = "uuid")
   public String getId() {
      return id;
   }

   public void setId(String id) {
      this.id = id;
   }

   /**
    * 报表标题
    */

   public String getTitle() {
      return title;
   }

   public void setTitle(String title) {
      this.title = title;
   }

   /**
    * 创建时间显示
    */
   @Transient
   public String getShowedDateString() {
      return new Tools().getShowedDateString(this.getTimestamp());
   }

   /**
    * 创建时间
    */
   public java.util.Calendar getTimestamp() {
      if (this.timestamp == null)
         return java.util.Calendar
               .getInstance(java.util.Locale.SIMPLIFIED_CHINESE);
      return this.timestamp;
   }

   public void setTimestamp(java.util.Calendar timestamp) {
      this.timestamp = timestamp;
   }

   /**
    * 单位领导
    */
   public String getUnitLeader() {
      return unitLeader;
   }

   public void setUnitLeader(String unitLeader) {
      this.unitLeader = unitLeader;
   }

   /**
    * 报表制作者
    */
   public String getReportMaker() {
      return reportMaker;
   }

   public void setReportMaker(String reportMaker) {
      this.reportMaker = reportMaker;
   }

   /**
    * 单位名称
    */
   @OneToOne
   public Department getUnitName() {
      return unitName;
   }

   /**
    * @param unitName
    *            the unitName to set
    */
   public void setUnitName(Department unitName) {
      this.unitName = unitName;
   }

   /**
    * @return reportMakerLocalName
    */
   public String getReportMakerLocalName() {
      return reportMakerLocalName;
   }

   /**
    * @param reportMakerLocalName
    *            the reportMakerLocalName to set
    */
   public void setReportMakerLocalName(String reportMakerLocalName) {
      this.reportMakerLocalName = reportMakerLocalName;
   }

   /**
    * @return 增加值率
    */
   @Min(value = 0)
   @Max(value = 1)
   public Float getIncreateRate() {
      if (this.increateRate == null)
         return 0.0f;
      return increateRate;
   }

   /**
    * @param increateRate
    *            the increateRate to set
    */
   public void setIncreateRate(Float increateRate) {
      this.increateRate = increateRate;
   }

   public void initialize() {
   }

   /**
    * @return the lastCulumateValue
    */
   public Double getLastCulumateValue() {
      return lastCulumateValue;
   }

   /**
    * @param lastCulumateValue
    *            the lastCulumateValue to set
    */
   public void setLastCulumateValue(Double lastCulumateValue) {
      this.lastCulumateValue = lastCulumateValue;
   }

   /**
    * @return the dateString
    */
   public String getDateString() {
      return dateString;
   }

   /**
    * @param dateString the dateString to set
    */
   public void setDateString(String dateString) {
      this.dateString = dateString;
   }
}


Reporter Class
Code:
package com.morepower.domain.report;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.apache.commons.collections.Closure;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.morepower.domain.util.LocalMonthVisitor;
import com.morepower.domain.util.NewProductionValueVistor;
import com.morepower.domain.util.TotalProductionValueVistor;

/**
* @author Administrator
* 軍品產量月快報
*/
@Entity
@DiscriminatorValue("AMPT")
public class ArmMonthProductReporter extends AbstractReporter {

   private List<ArmItem> armItems = new ArrayList<ArmItem>();
   private ArmMonthProductReporter lastMonthReporter;
   
   
   /**
    *
    */
   public ArmMonthProductReporter() {
      // TODO Auto-generated constructor stub
   }

   /**
    * 产品上报项目
    * */
   @OneToMany()
   @Cascade( {CascadeType.SAVE_UPDATE,CascadeType.DELETE ,CascadeType.DELETE_ORPHAN})
   @LazyCollection(LazyCollectionOption.EXTRA)
   @Fetch(FetchMode.JOIN)
   @JoinTable(name = "reporter_items", joinColumns = { @JoinColumn(name = "reporter_id")

   }, inverseJoinColumns = @JoinColumn(name = "armitem_id"))   
   public List<ArmItem> getArmItems() {
      return armItems;
   }

   public void setArmItems(List<ArmItem> armItems) {
      this.armItems = armItems;
   }

   /**
    * @return 本月产值
    * */
   @Transient
   public Double getLocalMonthValue() throws Exception {
      LocalMonthVisitor visitor = new LocalMonthVisitor();
      for (ArmItem item : this.getArmItems())
         item.accetp(visitor);

      return visitor.getValue();
   }
   
   /**
    * @return 本月总产值
    * */
   @Transient
   public Double getLocalMonthTotalValue() {
      TotalProductionValueVistor vistor = new TotalProductionValueVistor();
      for (ArmItem item : this.getArmItems())
         item.accetp(vistor);

      return vistor.getValue();
   }

   /**
    * @return 累计总产值 = 本月完成+上月累计
    */
   @Transient
   public Double getTotalCumulateValue() {
      
      LocalMonthVisitor visitor = new LocalMonthVisitor();
      ArmMonthProductReporter last = getLastMonthReporter();
      for(ArmItem item : this.getArmItems())
         visitor.visite(item);
      Double tcv = visitor.getValue()+this.getLastCulumateValue();
       return last==null?tcv:(tcv+last.getTotalCumulateValue());
   }
   
   /**
    * @return 本月新品总产值
    * */
   @Transient
   public Double getNewTotalValue() {
      NewProductionValueVistor vistor = new NewProductionValueVistor();
      for (ArmItem item : this.getArmItems())
         item.accetp(vistor);
      return vistor.getValue();
   }

   /**
    * @return the lastMonthReporter
    */
   @Transient
   public ArmMonthProductReporter getLastMonthReporter() {
      return lastMonthReporter;
   }

   /**
    * @param lastMonthReporter the lastMonthReporter to set
    */
   public void setLastMonthReporter(ArmMonthProductReporter lastMonthReporter) {
      this.lastMonthReporter = lastMonthReporter;
   }
   
   /**
    * @return  累计值 = 本月值 + 上月累计值
    * */
   @Transient
    public void mergeItems(){
      final ArmMonthProductReporter last  =   this.getLastMonthReporter();
      if(last == null )return;
      final ArmMonthProductReporter me = this;
      CollectionUtils.forAllDo(this.getArmItems(), new Closure(){
         public void execute(Object arg0) {
            ArmItem item = (ArmItem) arg0;
            ArmItem lastitem = me.getArmItemByCode(item.getCode(), last.getArmItems());
            item.setTotalValue(item.getLocalMonthValue()+lastitem.getTotalValue()); 
         }         
      });      
   }
   @Transient
   ArmItem getArmItemByCode(final String code , Collection<ArmItem> items){
      return  (ArmItem) CollectionUtils.find(items, new Predicate(){
         public boolean evaluate(Object arg0) {
            ArmItem i = (ArmItem) arg0;
            if(code.equalsIgnoreCase(i.getCode().trim()))
               return true;
            return false;
         }
          
       });
      
   }
   
}

USE Interceptor To load reporter list

Code:
    package com.morepower.xwork.interceptor;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.morepower.domain.services.reporter.ReporterServices;

import com.morepower.controller.reporter.ReporterCRUDAction;
import com.morepower.domain.Department;
import com.morepower.domain.User;
import com.morepower.util.SessionKey;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionInvocation;

public class ReporterListInterceptor extends AbstractBiznessInterceptor {

   static Collection<String> authors = new HashSet<String>();

   public void destroy() {

   }

   public void init() {
      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      SAXReader reader = new SAXReader();
      String[] types = { "arm" };
      try {
         Document document = reader.read(loader
               .getResourceAsStream("reporterauth.xml"));
         for (String type : types) {
            List list = document.selectNodes("/reporters/reporter[@type='"
                  + type + "']/acegirole");
            for (Object node : list) {
               Node n = (Node) node;
               authors.add(n.getText().trim());
            }
         }
      } catch (DocumentException e) {         
         e.printStackTrace();
      }

   }

   public String intercept(ActionInvocation arg0) throws Exception {

      List beans = null;
      ActionContext ctx = arg0.getInvocationContext();
      Map session = ctx.getSession();
      String auth = (String) session.get(SessionKey.CURRENTAUTH);
      User user = (User) session.get(SessionKey.LOGINUSER);
      ReporterCRUDAction aa = (ReporterCRUDAction) arg0.getAction();
      Department dept = user.getDepartment();
      ReporterServices services = aa.getServices();
      if (authors.contains(auth)) {
         beans = services.getReporters();
      } else {
         beans = services.getReporters(dept);
      }
      Map req = (Map) ctx.get("request");
      req.put("beans", beans);
      return arg0.invoke();
   }
}


Exception :
Code:
INFO : Hibernate SQL:                     - 2008-08-22 12:17:08,875  [com.morepower.dao.hibernate3.report.AMPReporterDAO] [Line:40]
INFO : from com.morepower.domain.report.ArmMonthProductReporter                     - 2008-08-22 12:17:08,875  [com.morepower.dao.hibernate3.report.AMPReporterDAO] [Line:41]
WARN : fail-safe cleanup (collections) : org.hibernate.engine.loading.CollectionLoadContext@149959a<rs=com.mysql.jdbc.ResultSet@1e3cabd>                     - 2008-08-22 12:17:08,890  [org.hibernate.engine.loading.LoadContexts] [Line:108]
WARN : On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries                     - 2008-08-22 12:17:08,890  [org.hibernate.engine.loading.CollectionLoadContext] [Line:329]
ERROR : Servlet.service() for servlet default threw exception                     - 2008-08-22 12:17:08,890  [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/stat].[default]] [Line:253]
java.lang.IllegalArgumentException
   at sun.reflect.GeneratedMethodAccessor122.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
   at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
   at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
   at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
   at org.hibernate.loader.Loader.doQuery(Loader.java:729)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
   at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
   at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:797)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241)
   at org.hibernate.loader.Loader.doList(Loader.java:2220)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at com.morepower.dao.hibernate3.HibernateDAO.getAny(HibernateDAO.java:42)
   at com.morepower.dao.hibernate3.report.AbstractReporterDAO.getReporters(AbstractReporterDAO.java:65)
   at org.morepower.domain.services.reporter.impl.AbstractServicesImpl.getReporters(AbstractServicesImpl.java:51)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy51.getReporters(Unknown Source)
   at com.morepower.xwork.interceptor.ReporterListInterceptor.intercept(ReporterListInterceptor.java:61)
   at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
   at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
   at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:273)
   at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at com.opensymphony.webwork.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:88)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
   at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
   at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
   at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
   at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
   at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
   at java.lang.Thread.run(Thread.java:595)

I' m puzzled for these errors ,i have five class inherited from AbstractReporter class ,these five object i have used one interceptor to refactor its CURD operoter , they have the same struture ,but this noon
when i do list ,these errors occured,i 'm puzzled,some meet it ,and can
tell me how to deal with !
thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.