org.hibernate.AssertionFailure: null id

org.hibernate.AssertionFailure: null id in cn.allobject.db.AReview entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1526)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at cn.allobject.daoimp.BasicDaoImp.<init>(BasicDaoImp.java:32)
at cn.allobject.factory.DAOFactory.basicFactory(DAOFactory.java:42)
at cn.allobject.struts.action.ShowMenuAction.execute(ShowMenuAction.java:72)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.java1995.filter.GZipFilter.doFilter(GZipFilter.java:38)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cn.allobject.servlet.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:34)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:283)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)
阅读更多

org.hibernate.AssertionFailure: null id in com.bean.Merchan entry (don't flush t

03-27

求大侠帮忙啊 rnrn#商品表rncreate table merchan(rnmerId int(2) not null primary key auto_increment,rnmerName varchar(20) not null,rntype_mer_id int(2),rnsecondType_mer_id int(2),rnsecondType_mer_id varchar(20),rnmerPrice decimal(8,2) not null,rnmerDiscount decimal(2,1),rnmerPicture varchar(100),rnmerDesc varchar(500),rnmerProducter varchar(20),rnmerLeaveDate timestamp,rnmerAddDate timestamp,rnsellNum int(2),rnallNum int(2),rnorder_mer_id int(2)rnrn)DEFAULT CHARSET=utf8; rnalter table merchan alter column merId set default '0';rnrnrn[color=#FF0000]Merchan.hbm.xml[/color]rnrnrnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn[color=#FF0000]我在保存对象的时候发生异常[/color]rnrn提交保存的代码如下:rnrnpublic class MerchanAction extends ActionSupportrn rn private static final long serialVersionUID = -7546549226738762677L;rn private static Logger log=Logger.getLogger(MerchanAction.class);rnrn private Map> merchanMap=new LinkedHashMap>();//用于存蓄商品rn private Integer id;//用于根据商品id删除/查找/更新商品对象rn private FirstTypeDao firstTypeDao;//通过依赖方式注入rn private SecondTypeDao secondTypeDao;//通过依赖方式注入rn private MerchanDao merchanDao;//通过依赖方式注入rn private Merchan merchan;//商品对象rn private File file;rn private String fileFileName;rn private String key;//商品关键字;rn private ListmerList=new ArrayList();// 商品集合rn private String time;//修改前台获取时间rn rn rn //保存商品对象rn @SuppressWarnings("deprecation")rn public String execute() throws Exceptionrn //取得上传图片保存的路径rn tryrn String targetDirectory=ServletActionContext.getRequest().getRealPath("/upload");rn //修改照片名字 保存照片名字为 System.currentTimeMillis().jpg rn rn String targetFileName=System.currentTimeMillis()+fileFileName.substring(fileFileName.indexOf("."));rn //生成上传的File对象rn File target = new File(targetDirectory, targetFileName);rn //放在File对象,从而实现上传文件rn FileUtils.copyFile(file, target); rn //设置图片的地址rn String address="upload"+"/"+targetFileName;rn // 为商品设置图片地址rn merchan.setMerPicture(address);rn //设置商品的添加时间rn tryrn merchan.setMerAddDate(DateTime.getTime());rn catch(Exception e)rn addActionMessage("是这里错误"+e.getMessage());rn rn //设置目前的商品销售数量 初始为0rn merchan.setSellNum(0);rn //设置商品出厂时间rn /*rn * time.equals( " "))当time为null时抛出NullPointerException. rn 而( " ").equals( time )不会。rn */rn rn if(("").equals(time)||time==null)rn merchan.setMerLeaveDate(null);rn elsern SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");rn String sdate=df.format(Date.valueOf(time));rn merchan.setMerLeaveDate(Timestamp.valueOf(sdate)) ;rn rn merchanDao.save(merchan);rn log.info("商品保存成功"+merchan.getMerName());rn catch(Exception e) rn e.printStackTrace();rn addActionError("地方"+e.getMessage());rn return "error";rn rn return SUCCESS;rn rnrn提交页面如下:rnrn rn rn 商品添加rn rn rn *商品类别:rn rn rn rn rn rn rn rn *商品名称rn rn rn rn 商品出厂地rn rn rn rn 厂家rn rn rn rn *商品价格rn rn rn rn *会员打折rn 只能输入(1-9)rn rn rn 商品出厂时间rn 按2012-03-21输入rn rn rn *商品图片rn rn rn rn rn rn rn *库存数量rn rn rn rn rn 商品描述rn rn rn rn 提示:*部分必须填rn rn rn rn rn rn rnrnrn

collection was not processed by flush() org.hibernate.AssertionFailure:

03-15

[dtss] 2012-03-15 12:30:58,515 ERROR [btpool0-3] org.hibernate.AssertionFailure.-22 | an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)rnorg.hibernate.AssertionFailure: collection [gov.sdta.dtss.domain.info.destination.Destination.distCenterList] was not processed by flush()rn at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)rn at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)rn at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)rn at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)rn at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:304)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:358)rn at $Proxy68.flush(Unknown Source)rn at org.springframework.orm.jpa.JpaTemplate$8.doInJpa(JpaTemplate.java:295)rn at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:184)rn at org.springframework.orm.jpa.JpaTemplate.flush(JpaTemplate.java:293)rn在程序中打上断点无法跟踪到错误源头,希望各位大虾帮帮忙、、、不胜感激!!!

没有更多推荐了,返回首页