首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

为什么小弟我执行hibernate查询的时候,会多执行了更新操作呢》?

2012-01-31 
为什么我执行hibernate查询的时候,会多执行了更新操作呢》??同上.Java code2011-03-28 09:09:44 [日志信息]

为什么我执行hibernate查询的时候,会多执行了更新操作呢》??
同上.

Java code
2011-03-28 09:09:44 [日志信息] Write Para1:null2011-03-28 09:09:44 [日志信息] Write Para1:/user.do2011-03-28 09:09:44 [日志信息] Write Para1:method=getList2011-03-28 09:09:44 [日志信息] Write Para1:/doUser.doHibernate: select count(*) as col_0_0_ from kejia.dbo.td_user tduser0_Hibernate: select top 18 tduser0_.id as id0_, tduser0_.userName as userName0_, tduser0_.password as password0_, tduser0_.name as name0_, tduser0_.role as role0_, tduser0_.addDate as addDate0_ from kejia.dbo.td_user tduser0_Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?Hibernate: update kejia.dbo.td_user set userName=?, password=?, name=?, role=?, addDate=? where id=?{"total":19,"data":[{"id":19,"name":"asfdasfd","role":0,"userName":"admin","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"admin"},{"id":20,"name":"dfasdf","role":0,"userName":"asdf222","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"as"},{"id":21,"name":"sdfasdf","role":0,"userName":"asdf","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"asfa"},{"id":22,"name":"3333","role":0,"userName":"dddd","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"dddd"},{"id":23,"name":"3333","role":0,"userName":"3333","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"333"},{"id":24,"name":"2323","role":0,"userName":"232","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"323"},{"id":25,"name":"23424","role":0,"userName":"234234","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"234"},{"id":26,"name":"234234","role":0,"userName":"234234","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"234"},{"id":28,"name":"4234234","role":0,"userName":"2342","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"34234"},{"id":29,"name":"2323","role":0,"userName":"22","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"323"},{"id":30,"name":"33","role":0,"userName":"333","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"33"},{"id":33,"name":"孙超","role":0,"userName":"sunchao","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"shuxhao"},{"id":34,"name":"23","role":0,"userName":"23","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"23"},{"id":37,"name":"bbbbb","role":0,"userName":"aaaaaaaaa","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"bbbb"},{"id":38,"name":"cccccccc","role":0,"userName":"aaaaaaa","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"bbbbbbbbbb"},{"id":39,"name":"haha","role":0,"userName":"hello","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"mima"},{"id":40,"name":"3333","role":0,"userName":"33333","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"3333"},{"id":41,"name":"ddddd","role":0,"userName":"ddddd","addDate":{"time":1301274584796,"minutes":9,"seconds":44,"hours":9,"month":2,"timezoneOffset":-480,"year":111,"day":1,"date":28},"password":"ddd"}],"success":true} 



[解决办法]
探讨

Java code

public void setAddDate(Date addDate) {
Date date = new Date();
this.addDate = date;
}



找到了。为什么我把set写成这样就会出现上面的问题呢?

[解决办法]
我也遇到这种情况,当时的情况就是因为实体类的date属性的set方法中直接date=new Date();
所以就会出现查询的时候也更新了!!不知道你的是什么回事!!

热点排行