- 浏览: 237144 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (172)
- J2SE学习模块 (35)
- Oracle学习模块 (12)
- Jsp学习模块 (11)
- Servlet学习模块 (1)
- Tomcat 模块 (4)
- Struts1.x学习模块 (5)
- Spring学习模块 (2)
- Hibernate学习模块 (11)
- XML学习模块 (1)
- UML学习模块 (0)
- 算法学习模块 (6)
- 设计模式模块 (2)
- Mysql学习模块 (1)
- SQL_Server学习模块 (8)
- 项目开发模块 (10)
- 搜索引擎 (14)
- 开发工具的使用 (2)
- 面试题集 (7)
- 开发工具 (8)
- Linux (5)
- JavaFX模块 (1)
- 程序与人生 (4)
- 计算机网络 (6)
- EJB学习模块 (1)
- javascript常用模块 (2)
- 英语学习 (1)
- 程序变量命名的几条法则:匈牙利命名法 (1)
- 驼峰式大小写 (1)
- 帕斯卡命名法 (1)
- Jquery控制图片宽度及高度 (1)
- 喜讯--FireFox7.01已经支持CSS中 text-overflow ellipsis 属性 (1)
- 遍历 Map 的三种 常用方法 java (1)
- JDK自带工具Jstat (1)
- 提高 Oracle 查询 效率 建议 (1)
- 常用工具 (1)
最新评论
-
a465492689:
挺好,谢谢分享
存储过程 -
huangqinghe:
ding 顶~~~
Intellij Idea12 中文乱码问题总结 -
Redpick13:
楼主好人啊,有耐心
Java中的二维数组的定义与学习 -
dandongsoft:
神鼎飞丹砂
java.lang.NoClassDefFoundError: org/apache/lucene/index/memory/MemoryIndex -
devil__lord:
不错讲得很清楚 color=#cff
Java中的二维数组的定义与学习
更新多条记录出错:Hibernate.
试图在一个Action中调用多次Hibernate插入数据,
因为插入前一条数据后在后一条插入数据中需要用到前一条的记录.
代码如下:
试图在一个Action中调用多次Hibernate插入数据,
因为插入前一条数据后在后一条插入数据中需要用到前一条的记录.
代码如下:
public ActionForward regUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { UserActionForm uaf = (UserActionForm)form; //取出从页面提交过来的数据 String name = uaf.getName(); String password = uaf.getPassword(); String password1 = uaf.getPassword1(); String nichen = uaf.getNichen(); String email = uaf.getEmail(); String province = uaf.getProvince(); String sex = request.getParameter("sex"); MD5 md5 = new MD5(); //将页面提交过来的数据设置进User类中 User user = new User(); user.setName(name); user.setEmail(email); user.setPassword(md5.getMD5ofStr(password)); user.setNichen(nichen); user.setSex(sex); user.setProvince(province); user.setRegTime(new java.sql.Timestamp(System.currentTimeMillis())); //调用业务逻辑方法 int flag = 0; try { flag = userManager.add_User(user); }catch(Exception e){ e.printStackTrace(); return mapping.findForward("add_fail"); } /** * 默认的方法是开通博客同时是发表一篇开通博客的日志. */ Blog blog = new Blog(); blog.setName(name); blog.setVisited(1); blog.setGrade(1); blog.setOnline(true); blog.setUser(user); blog.setLastLoginTime(new java.sql.Timestamp(System.currentTimeMillis())); blog.setMingyuan("OpenSource社区博客中心欢迎你"); blog.setHead(null); /** * 发表一篇开通博客的日志... */ Daily daily = new Daily(); daily.setTitle("用户"+user.getName()+"开通博客--"+name); daily.setContent("<font size='4'><p>感谢用户:<font color='white' size='3'>"+user.getName()+"</font>在OpenSource开源社区中心开通博客</p>" + "<p>若有任何问题及意见,请发邮件到*****@163.com或者致电到:*****或者QQ交谈:******</p>" + "<p>如果发生问题,我们会尽快帮你解决你所提出的问题,你的意见及问题是我们开源社区前进的动力!</p>"+ "<p>谢谢你的合作!</p></font><p align='right'>开发团队PPP敬上!</p>"); daily.setVisited(0); daily.setPostTime(new java.sql.Timestamp(System.currentTimeMillis())); int flag2 = 0; try { flag2 = blogManager.add_Blog(blog); }catch(Exception e){ e.printStackTrace(); return mapping.findForward("add_fail"); } daily.setBlog(blog); try { dailyManager.add_Daily(daily); }catch(Exception e){ e.printStackTrace(); return mapping.findForward("add_fail"); } if(flag==1 && flag2==1){ return mapping.findForward("add_success"); }else { return mapping.findForward("add_fail"); } }
javax.servlet.ServletException: org.hibernate.AssertionFailure: null id in com.hpjianhua.xiehui.model.User entry (don't flush the Session after an exception occurs) org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77) root cause org.hibernate.AssertionFailure: null id in com.hpjianhua.xiehui.model.User entry (don't flush the Session after an exception occurs) org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:55) org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:157) org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113) org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196) org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76) org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338) org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:558) org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:540) org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:510) org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:310) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:117) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209) $Proxy24.add_User(Unknown Source) com.hpjianhua.xiehui.web.action.UserAction.regUser(UserAction.java:52) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270) org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) com.hpjianhua.xiehui.web.action.BaseAction.execute(BaseAction.java:18) org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
评论
3 楼
hpjianhua
2010-04-30
看看兄弟写的Action代码是如何的呢?谢谢了
2 楼
rainlife
2010-04-30
>>因为插入前一条数据后在后一条插入数据中需要用到前一条的记录
先去了解一下hibernate的基础知识吧
-----------------------------------
Action的代码,简直惨不忍睹
先去了解一下hibernate的基础知识吧
-----------------------------------
Action的代码,简直惨不忍睹
1 楼
hpjianhua
2010-04-30
请问解决方法....谢谢了..
发表评论
-
Hibernate三种状态的转换
2010-09-22 10:23 575hibernate的状态 hibernate ... -
Hibernate实战Hibernate in action[英文版电子书][PDF]
2010-04-08 21:00 2114Hibernate实战Hibernate in action[ ... -
Hibernate回调与拦截机制
2009-06-14 02:04 818以下内容转载自:http://topmanopensourc ... -
Hibernate事务管理与乐观悲观锁定义
2009-06-14 01:53 1482Hibernate事务管理 数据 ... -
Hibernate脏数据与数据缓存
2009-06-14 01:44 1623Hibernate脏数据检查 何 ... -
Hibernate实体对象的生命周期
2009-06-13 11:19 522一.Hibernate实体对象的生命周期 实体对象的3种状态 ... -
Hibernate 自定义持久化实现
2009-06-13 10:17 830Hibernate 自定义持久化实现 在Hibernate ... -
Hibernate 数据加载方式
2009-06-13 09:58 954Hibernate数据加载方式 Hi ... -
HQL实用技术
2009-06-12 21:16 1269Fb HQL实用技术 实体查询 简单例子: String ... -
Hibernate学习笔记
2009-05-31 21:31 756第一个hibernate项目 1、新建java项目 2、创 ...
相关推荐
博文链接:https://llying.iteye.com/blog/221702
session.flush()和session.clear()就针对session的一级缓存的处理。 简单的说, 1 session.flush()的作用就是将session的缓存中的数据与数据库同步。 2 session.clear()的作用就是清除session中的缓存数据(不管缓存...
Embedded: You can use RaptorDB inside your application as you would any other DLL, and you don't need to install services or run external programs. NoSQL: A grass roots movement to replace relational...
out.flush(); out.close(); out.write(parameters.getBytes(),0,parameters.getBytes().length); InputStream in = hc.getInputStream(); InputStreamReader reader = new InputStreamReader(in,"gb...
By leveraging the Address Windowing Extensions API, an application can create a fixed-size window into the additional physical memory. This allows a process to access any portion of the physical ...
an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) net.sf.hibernate.AssertionFailure: possible nonthreadsafe access to session ...
clflush should apparently flush the cache line on all processors in an SMP system.
三星flush接口定义图解三星flush接口定义图解
This is the maximum size of an area which will be flushed. If the area is larger than this, then we flush the whole cache.
This specification is intended to be an open standard, and as such the text and information contained herein may be freely used, copied, or distributed without compensation or licensing restrictions. ...
Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked. doFilter(ServletRequest, ...
An empty string can be denoted by simply not writing anything after the equal ; sign, or by using the None keyword: ; foo = ; sets foo to an empty string ; foo = None ; sets foo to an empty string ;...
module_pg_flushbuffer
对hibernate的flush机制有兴趣可以看看
flush插件下载
注意:ob_flush()和flush()这两个函数一般要一起使用,顺序是先ob_flush(),然后flush(),它们的作用是刷新缓冲区。这里具体的说下什么时候要用到刷新缓冲区和为什么要刷新缓冲区。 一、什么时候要刷新缓冲区 当...
主要介绍了Hibernate的Session_flush与隔离级别代码详解,分享了相关代码示例,小编觉得还是挺不错的,具有一定借鉴价值,需要的朋友可以参考下
MySQL-Flush命令用法.docx#资源达人分享计划#
* added a flush after every log line to help GUIs * "eac3to some.mpls" now also works if the stream files aren't there, anymore * fixed: number of subtitles was not appended to demuxed subtitles' file...
Some ColdFire parts implement separate instruction and data caches, on those we should just flush the appropriate cache. If we don t need to do any specific flushing then this will be optimized away.