hibernate保存数据报错

org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [insert into ORC_T_BUSINESS_TRACK (BUSI_NUM, BUSI_TYPE, CREATE_DATE, CREATE_USER_NAME, CREATE_USER_NUM, REMARK, ID) values (?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:643)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:516)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:394)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.bsteel.shdc.service.OrcTBusinessTrackServiceImpl$$EnhancerByCGLIB$$416c9ca9.saveOrcTBusinessTrack()
at com.bsteel.shdc.bankservice.finance.redeem.controller.AuditController.signaTure1(AuditController.java:642)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
at com.bsteel.shdc.manager.permission.filter.AuthFilter.doFilter(AuthFilter.java:101)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512)
... 47 more
Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:345)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10844)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 56 more

[color=red][/color]

3个回答

1.插入的数据中,有的字段为null,但是数据库表限制该字段不能为null
[code="java"] Could not execute JDBC batch update; SQL [insert into ORC_T_BUSINESS_TRACK (BUSI_NUM, BUSI_TYPE, CREATE_DATE, CREATE_USER_NAME, CREATE_USER_NUM, REMARK, ID) values (?, ?, ?, ?, ?, ?, ?)]; constraint [null];[/code]

2.批量更新数据时,有些数据的字段值超过了数据库表定义的字段最大值,要么扩大该字段的值,要么对插入的数据进行校验
[code="java"]Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column[/code]

sadasafsdfdsf
sadasafsdfdsf 对 就是一个 字段太长了 是USER对象里面的一个字段本来是ID保存成Name了然后在写入数据库时长度过大 不知道谁动了项目里的字段了 奶奶的
5 年多之前 回复

Could not execute JDBC batch update; SQL [insert into ORC_T_BUSINESS_TRACK (BUSI_NUM, BUSI_TYPE, CREATE_DATE, CREATE_USER_NAME, CREATE_USER_NUM, REMARK, ID) values (?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException

没有代码 只能从你上面报出的异常来 推测
1.可能你数据库里面的字段设置不能为空 但是你往做句库做动作的时候 这个字段上的值是空的

2.可能是配置文件设置了关联,数据却没有关联造成的,只要数据正确就没有问题。

另外,造成这个原因的还可能是数据库的驱动jar包不支持。
3.因为Hibernate Tools(或者Eclipse本身的Database Explorer)生成*.hbn.xml工具中包含有catalog="***"(*表示数据库名称)这样的属性,将该属性删除就可以了
4.估计是你的列名里面有关键字的原因吧,命名列的时候不要单独使用date,ID...这种关键字

其实吧,出现异常,定位的话只要看Caused by后面的就行了。。
Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column
有个字段的值太大了。。就这么简单。。目测是某个字符串长度没给够,自己检查下数据库表和hibernate配置文件吧

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
hibernate 配置文件报错
![图片说明](https://img-ask.csdn.net/upload/201701/03/1483440537_361655.png) 之前是create没问题,换成update就报错,但还是能执行。不过第二天数据库就报10061错误,不清楚问题到底出在哪里。下面是我的全部代码。 配置文件: <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <property name="connection.username">root</property> <property name="connection.url">jdbc:mysql://localhost:5656/mysql</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="connection.password">123456</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resource="Students.hbm.xml"/> </session-factory> </hibernate-configuration> 测试文件: import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.Date; public class Studentstest { private SessionFactory sessionFactory; private Session session; private Transaction transaction; @Before public void init() { //创建配置对象 Configuration config = new Configuration().configure(); //创建服务注册对象 // ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); //创建会话工厂对象 ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build(); sessionFactory = config.buildSessionFactory(serviceRegistry); //会话对象 session = sessionFactory.openSession(); //开启事务 transaction = session.beginTransaction(); } @After public void destory() { transaction.commit(); //提交事务 session.close(); //关闭会话 sessionFactory.close(); //关闭会话工厂 } @Test public void testSaveStudents() {//增加 //生成学生对象 Students s = new Students(); s.setSname("POLY Ma"); s.setBirthday(new Date()); s.setAddress("Hong Kong"); s.setGender("M"); session.save(s); //保存对象进入数据库 } @Test public void search(){//查找 Students s=session.get(Students.class,1);//1 is primary key System.out.print(s); } @Test public void update(){//修改 Students s=session.get(Students.class,2);//look on s.setAddress("Hang Zhou"); session.update(s); } @Test public void delete(){//删除 Students s=session.get(Students.class,1); session.delete(s); } } 映射文件: <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="Students" table="students"> <id name="sid" type="int"> <column name="sid"/> <generator class="native"/> </id> <property name="sname" type="java.lang.String"> <column name="sname"/> </property> <property name="gender" type="java.lang.String"> <column name="gender"/> </property> <property name="birthday" type="date"> <column name="birthday"/> </property> <property name="address" type="java.lang.String"> <column name="address"/> </property> </class> </hibernate-mapping> 主体: import java.util.Date; /** * Created by tcxd on 2016/12/28. */ public class Students { private int sid; //学号 private String sname; //姓名 private String gender; //性别 private Date birthday; //出生日期 private String address; //地址 public Students() { } public Students(int sid, String sname, String gender, Date birthday, String address) { this.sid = sid; this.sname = sname; this.gender = gender; this.birthday = birthday; this.address = address; } public int getSid() { return sid; } public void setSid(int sid) { this.sid = sid; } public String getSname() { return sname; } public void setSname(String sname) { this.sname = sname; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public void setAddress(String address) { this.address = address; } public String getAddress() { return address; } @Override public String toString() { return "Students{" + "sid=" + sid + ", sname='" + sname + '\'' + ", gender='" + gender + '\'' + ", birthday=" + birthday + ", address=" + address + '}'; } }
测试hibernate框架自动建表并保存数据,没报错,但数据只保存了一部分
![图片说明](https://img-ask.csdn.net/upload/201603/23/1458711095_350255.jpg)
hibernate 保存对象到数据库
Illegal attempt to associate a collection with two open sessions 报错
springboot JPA保存报错
用户类 ``` @Entity @SecondaryTable(name="sys_user_extend") @GenericGenerator(name = "jpa-uuid", strategy = "uuid") public class SysUser implements UserDetails { /** * */ private static final long serialVersionUID = 1L; public SysUser() { } public SysUser(String loginName, String password) { super(); this.loginName = loginName; this.password = password; } @Id @GeneratedValue(generator = "jpa-uuid") private String id; @Column(unique=true ,nullable = false) private String loginName; @Column(nullable = false) private String password; @Column(unique=true ,nullable = false) private String name; @Column(unique=true) private String email; @Column(unique=true) private String phone; @Column private String remark; @Column private String lastLoginTime; @Column(nullable = false) private String isActive = "true"; @Column(table="sys_user_extend") private String level; @Column(table="sys_user_extend") private String currentExperience; @Column(table="sys_user_extend") private String totalExperience; @ManyToMany(cascade = { CascadeType.REFRESH }, fetch = FetchType.EAGER) private List<SysRole> roles; @Override public Collection<? extends GrantedAuthority> getAuthorities() { List<GrantedAuthority> authorities = new ArrayList<>(); List<SysRole> roles = this.getRoles(); for (SysRole role : roles) { authorities.add(new SimpleGrantedAuthority(role.getName())); } return authorities; } //省略get、set方法 } ``` ``` public interface SysUserRepository extends JpaRepository<SysUser, Long> { SysUser findByLoginName(String loginname); SysUser findByPhone(String phone); SysUser findByEmail(String email); } ``` controller层的添加方法 ``` //添加 @ResponseBody @RequestMapping(value="/user",method=RequestMethod.POST) public Object post(@RequestBody SysUser user){ BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String encodedPassword = passwordEncoder.encode(user.getPassword()); user.setPassword(encodedPassword); userserivce.saveUser(user); return user; } ``` ![数据库用户表](https://img-ask.csdn.net/upload/201909/24/1569312948_464905.png) ![数据库用户扩展信息表](https://img-ask.csdn.net/upload/201909/24/1569313009_372653.png) 报错信息: > org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: (was java.lang.NullPointerException); nested exception is com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: com.sakuraSmiles.alpha.security.model.SysUser[\"authorities\"])" 测试json {"loginName":"test123","name":"测试","password":"123456","level":"5"} 项目使用了spring security,通过postman模拟请求,debug跟了下发现controller层的user是能拿到我传的对象的,但是里面也没有authorities字段。网上找了好久也没看到有跟我这个类似的,请问有人碰到过相似的问题吗?或者有大佬帮忙看一看吗? 感谢1楼和3楼大牛的解答帮助,十分感谢两位的帮助。分想要两位都给的,没办法只能选择一个采纳,就先给了1楼。问题已经解决了,定位到就是如3楼大牛所说,因为实现UserDetails 接口会有getAuthorities方法,在进行序列化时发现有带getXX开始的方法会自动去找XX的属性, 但是发现并没这个属性,所以报错。网上搜索了一下jpa有没有能够让系统能够忽视这个get方法的注释,在getAuthorities方法上面添加了@JsonIgnore就执行save不会报错了,目前没看出对于其他地方有没有影响。 ``` @Override @JsonIgnore public Collection<? extends GrantedAuthority> getAuthorities() { List<GrantedAuthority> authorities = new ArrayList<>(); List<SysRole> roles = this.roles; for (SysRole role : roles) { authorities.add(new SimpleGrantedAuthority(role.getName())); } return authorities; } ``` ![图片说明](https://img-ask.csdn.net/upload/201909/24/1569316069_705652.png)
Help!求助:Hibernate整合JPA后测试增、删、改、查报错
小弟新手,刚开始学习开发,最近出现一个问题,求各位大神指教,小弟万分感谢! 在做的是一个体系分级,已经实现了针对一级表的增、删、改、查,这里是正常的。 但是在做二级表时报错。二级表与一级表的区别只是:增加了一级主键ID。 下面图片是代码: ![图片说明](https://img-ask.csdn.net/upload/201709/01/1504227247_38118.png) ![图片说明](https://img-ask.csdn.net/upload/201709/01/1504227261_327178.png) ![图片说明](https://img-ask.csdn.net/upload/201709/01/1504227273_19660.png) ![图片说明](https://img-ask.csdn.net/upload/201709/01/1504227284_575148.png) 下面是数据表:标红框的地方是上级ID标识。 ![图片说明](https://img-ask.csdn.net/upload/201709/01/1504227455_774857.png) 下面是报错信息: 1. 保存报错: 非法参数异常发生 javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.byebook.bean.study.CyYw1KP2.kpID 非法参数异常发生 Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.byebook.bean.study.CyYw1KP2.kpID 对象不是声明类的实例。 Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class 2. 查询报错: ① javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID ② Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID 3. 删除报错: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID ① Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID ② Caused by: java.lang.IllegalArgumentException: argument type mismatch 4. 更新报错: ① javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID ② Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.byebook.bean.study.CyYw1KP2.kp1ID ③ Caused by: java.lang.IllegalArgumentException: argument type mismatch 求各位大神指教,小弟再次万分感谢!!!
使用注解生成的uuid.hex 调用save()保存对象不发语句也不报错
``` @Id @GenericGenerator(name="systemUUID",strategy="uuid") @GeneratedValue(generator="systemUUID") @Column(name = "ID", unique = true, nullable = false, length = 32) public String getId() { return this.id; } ```实体类的部分代码如上,在调用save方法的时候不报错也不保存,数据库中没有数据。平时主键使用int类型,自动增长,调用save就可以,现在公司要用varchar作为主键,调用save方法不报错,也不报错,我快崩溃了,该怎么办
java 保存clob类型数据是报错怎么解决
实体类型: ``` /** *方法: 取得java.lang.Clob *@return: java.lang.Clob 学习内容 */ @Column(name ="STUDY_CONTENT",nullable=true,length=4000) public java.sql.Clob getStudyContent() { return studyContent; } /** *方法: 设置java.lang.Clob *@param: java.lang.Clob 学习内容 */ public void setStudyContent(java.sql.Clob studyContent) { this.studyContent = studyContent; } ``` 数据库字段: ![图片说明](https://img-ask.csdn.net/upload/201611/15/1479196609_159328.png) 报错信息: ``` [org.jeecgframework.core.common.exception.GlobalExceptionResolver]全局处理异常捕获: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object 'djIntStudyEntity' on field 'studyContent': rejected value [<p>学习内容</p>]; codes [typeMismatch.djIntStudyEntity.studyContent,typeMismatch.studyContent,typeMismatch.java.sql.Clob,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [djIntStudyEntity.studyContent,studyContent]; arguments []; default message [studyContent]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.sql.Clob' for property 'studyContent'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [java.sql.Clob] for property 'studyContent': no matching editors or conversion strategy found] at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:818) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:367) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) at javax.servlet.http.HttpServlet.service(HttpServlet.java:646) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.jeecgframework.core.aop.GZipFilter.doFilter(GZipFilter.java:49) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:140) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:119) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) ```
java hibernate级联保存
![![图片说明](https://img-ask.csdn.net/upload/201501/18/1421582430_407257.png)图片说明](https://img-ask.csdn.net/upload/201501/18/1421582416_713571.png) 我用的是级联保存,已保存就报这样的错,实体类user从数据库中查出来的,求大神解决
hibernate Spring save指令无法保存
使用了save指令 但是控制台没有输出insert语句 也没有报错 没有保存数据 ```@Entity public class Payroll{ @Id @GeneratedValue private long pid; private long sid; //结账日期 private Timestamp date; //累结 private double totalSum; //结余 private double balance; //伙食费用 private double boardWages; //扣款 private double deduct; //欠款 private double debt; ///预支 private double advance; //薪水细则 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name="pid") private List<PayrollRow> payrollRow = new ArrayList<PayrollRow>(); //省略GETTER SETTER } ``` ``` @Entity public class PayrollRow { @Id @GeneratedValue private long prid; private String style_number; private String process; private int count; private double cost; private double amount; // } ``` DAO层 ``` @Repository public class PayrollDAOImpl implements PayrollDAO{ @Autowired SessionFactory sessionFactory; public boolean save(Payroll p) { // TODO Auto-generated method stub try { System.out.println("info"+sessionFactory.getCurrentSession().save(p)); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return false; } return true; } public boolean saveRow(PayrollRow pr){ // TODO Auto-generated method stub try { System.out.println("info"+sessionFactory.getCurrentSession().save(pr)); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return false; } return true; } } ``` service层 ``` @Service @Transactional public class PayrollServiceImpl implements PayrollService { @Autowired PayrollDAOImpl payrollDAO ; public boolean save(Payroll payroll){ List<PayrollRow> pwl = payroll.getPayrollRow(); for (int i = 0;i<pwl.size();i++) { payrollDAO.saveRow(pwl.get(i)); System.out.println("info "+i); } return payrollDAO.save(payroll); } } ``` 配置文件 ``` <!-- 支持注解 --> <mvc:annotation-driven /> <!--自动装配DefaultAnnotationHandlerMapping和AnnotationMethodHandlerAdapter --> <mvc:default-servlet-handler /> <!-- 设置自动扫描的路径,用于自动注入bean 这里的路径与自己的项目目录对应--> <!-- 扫描controller路由控制器 --> <context:component-scan base-package="pres.uiiooo.controller" /> <context:component-scan base-package="pres.uiiooo.daoimpl,pres.uiiooo.serviceimpl" /> <!-- 视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="suffix" value=".jsp" /> <!-- 视图文件类型 --> <property name="prefix" value="/WEB-INF/views/" /> <!-- 视图文件的文件夹路径 --> </bean> </beans> ``` ``` <!-- JNDI(通过Tomcat)方式配置数据源 --> <!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jndiName}"></property> </bean> --> <!-- 引入属性文件 --> <context:property-placeholder location="classpath:config.properties" /> <!-- 配置数据源 这里class可以使用不同的驱动--> <bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc_driverClassName}" /> <property name="url" value="${jdbc_url}" /> <property name="username" value="${jdbc_username}" /> <property name="password" value="${jdbc_password}" /> </bean> <!-- 配置hibernate session工厂 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="current_session_context_class">thread</prop> </props> </property> <!-- 自动扫描注解方式配置的hibernate类文件 --> <property name="packagesToScan"> <list> <!-- 此处与entity实体路径对应 --> <value>pres.uiiooo.model</value> </list> </property> </bean> <!-- 配置事务管理器 --> <bean name="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 注解方式配置事物 --> <tx:annotation-driven transaction-manager="transactionManager" /> </beans> ``` 其他的DAO层save是可用的 但是这个不行 应该是涉及到事务管理配置 还有一对多配置方面的问题 求大佬解决 谢谢谢谢了!!!
如何通过hibernate存取日期
比如我要将表单中的2011-08-12这个日期存入数据库。我的实体该将这字段映射成什么类型?我将它映射成Date。可是保存时后台直报错。大家都是怎样做的?我已经弄了一天了,还是不行。我用的框架是spring mvc hibernate mysql。
hibernate 一对多的保存问题,望赐教
one public class DCompany extends BaseEntity { /** * */ private static final long serialVersionUID = 2472916124848152035L; /** * 公司标识 */ @Id @GeneratedValue(generator = "paymentableGenerator") @GenericGenerator(name = "paymentableGenerator", strategy = "uuid") private String comId; /** * 公司名称 */ private String comName; /** * 用户信息 */ @OneToMany(fetch = FetchType.LAZY) @JoinColumn(name = "comId") private List<DUser> users; /** * 公司地址 */ private String comAddress; /** * 公司经营类别 */ private String comType; /** * 公司简介 */ private String comIntro; /** * 公司电话 */ private String comTel; /** * 增加时间 */ private String comCreateDate; many public class DUser extends BaseEntity { /** * */ private static final long serialVersionUID = -7733922431721279323L; /** * 用户标识 */ @Id @GeneratedValue(generator = "paymentableGenerator") @GenericGenerator(name = "paymentableGenerator", strategy = "uuid") private String userId; /** * 姓名 */ private String userName; /** * 所属公司信息 */ @ManyToOne @JoinColumn(name = "comId") private DCompany company; /** * 性别标识M.男F.女 */ private String userSex; /** * 密码 */ private String userPass; /** * Email */ private String userEmail; /** * 电话 */ private String userTel; /** * qq */ private String userQq; /** * 是否冻结 0冻结 1正常 */ private Integer userEnable; /** * 创建时间 */ private Timestamp userCreateDate; 现在数据库里的数据都是空的,没有记录,我想实现的是DCompany 和DUser一起保存在数据库中 比如jsp页面文本框信息如下: 公司名: 公司地址: 公司电话: 姓名: 性别: QQ: 也就是页面上一次录入DCompany 实体信息与DUser实体信息,然后一点保存,分别把DCompany 信息保存到DCompany 表,DUser信息保存到DUser表中 我的测试代码是这么写的: DCompany company = new DCompany(); company.setComName("北京时间有限公司"); company.setComAddress("朝阳区酒仙桥1号"); company.setComIntro("介绍信息写这里"); company.setComTel("010-38782121"); company.setComType("test"); DUser user = new DUser(); user.setUserName("test"); user.setUserEmail("test@188.com"); user.setUserPass("123afb"); user.setUserEnable(1); user.setUserSex("M"); user.setUserTel("13811112121"); user.setUserQq("21232221"); List list = new ArrayList(); list.add(user); company.setUsers(list); companyService.saveCompany(company); 可是保存不进去,DUser表里有comId,这样以来如果没有先保存DCompany 信息是不会有comId的,报错 object references an unsaved transient instance - save the transient instance before flushing: org.wdj.base.entity.DUser; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.wdj.base.entity.DUser 请问 该如何做呢,谢谢
hibernate的session.save()为什么没有执行
User 是一个有id username passwrod的类 hb.cfg.xml <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 先配置数据库链接信息 --> <property name = "connection.driver_class">com.mysql.jdbc.Driver</property> <property name = "connection.url">jdbc:mysql://localhost:3306/dxlin</property> <property name = "connection.username">root</property> <property name = "connection.password">duanlin113</property> <property name="javax.persistence.validation.mode">none</property> <!-- 数据库方言 --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <mapping resource = "com/dxlin/pojo/person.hbm.xml"/> </session-factory> </hibernate-configuration> User.hbm.xml <?xml version="1.0" ?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package = "com.dxlin.pojo"> <class name = "com.dxlin.pojo.User" table = "User"> <id name = "id"> <!-- 主键生成策略 --> <generator class="native" column = "id"></generator> </id> <property name="username" column = "username"/> <property name="password" column = "password"/> </class> </hibernate-mapping> Test 类 package com.dxlin.hibtest; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import com.dxlin.pojo.User; public class Test { public static void main(String args[]) { System.out.println("1"); //1.新建立Configuration对象 Configuration cfg = new Configuration(); cfg.configure("hb.cfg.xml"); System.out.println("2"); //2.通过Configuration新建sessionFactory对象 ServiceRegistry registry = new StandardServiceRegistryBuilder() .applySettings(cfg.getProperties()) .build(); SessionFactory sf = cfg.buildSessionFactory(registry); System.out.println("3"); //3.通过sessionFactory得到session Session session = sf.openSession(); System.out.println("4"); //4.通过session对象得到Transaction对象 Transaction tx = session.beginTransaction(); System.out.println("5"); //保存数据 User user = new User(); user.setUsername("DL2"); user.setPassword("002"); session.save(user); System.out.println("6"); //提交事务 tx.commit(); System.out.println("7"); //关闭session session.close(); System.out.println("8"); } } 代码不报错,运行为 ![图片说明](https://img-ask.csdn.net/upload/201710/15/1508064451_919348.png)
新手学习hibernate出错
myeclipse下保存操作,可以把数据保存到数据库,但是启动tomcay后就会在控制台报错如下:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO),如何解决?网上查了好久还是没有解决,密码和用户名没有错误。
慕课网案例 新手Hibernate配置问题,单表操作
搞了两天了,一直卡在这。百度了好多也没找到解决方案,希望大家帮我看看。 **编程环境** * Eclipse Neon.3 Release (4.6.3) * hibernate(5.3.0) * JDBC8.0.11 * MySQL5.6 **报错信息** ``` Apr 23, 2018 5:06:42 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.3.0.CR1} Apr 23, 2018 5:06:42 PM org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found Apr 23, 2018 5:06:42 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.2.Final} Apr 23, 2018 5:06:42 PM org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead. Support for obsolete DTD/XSD namespaces may be removed at any time. Apr 23, 2018 5:06:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) Apr 23, 2018 5:06:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hibernate?serverTimezone=UTC] Apr 23, 2018 5:06:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {user=root, password=****} Apr 23, 2018 5:06:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false Apr 23, 2018 5:06:43 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init> INFO: HHH000115: Hibernate connection pool size: 20 (min=1) Apr 23, 2018 5:06:43 PM org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect Apr 23, 2018 5:06:44 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@24be2d9c] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. ``` **项目结构** ![图片说明](https://img-ask.csdn.net/upload/201804/23/1524474801_956742.png) **项目内容** hibernate.cfg.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 1.设置四本一言 --> <!-- 驱动,连接URL,用户名,密码,方言 --> <property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?serverTimezone=UTC</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">123456</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="current_session_context_class">thread</property> <!-- 2.全局配置信息 --> <!--是否显示SQL语句 --> <property name="show_sql">true</property> <!--是否格式化SQL语句 --> <property name="format_sql">true</property> <!--执行DDL的类别: create:每次都删除新建 update:存在就修改,不存在就新建 --> <property name="hbm2ddl.auto">update</property> <!--3.加载配置文件 --> <!--基于xml映射文件: 映射文件加载。路径 --> <mapping resource="Student.hbm.xml"/> <!-- <mapping class="Students"/> --> </session-factory> </hibernate-configuration> ``` Student.java ``` import java.util.Date; public class Student { private int sId; private String sName; private String gender; private Date birthday; private String address; public Student() { } public Student(int sId, String sName, String gender, Date birthday, String address) { this.sId = sId; this.sName = sName; this.gender = gender; this.birthday = birthday; this.address = address; } @Override public String toString() { return "Student [sId=" + sId + ", sName=" + sName + ", gender=" + gender + ", birthday=" + birthday + ", address=" + address + "]"; } public int getsId() { return sId; } public void setsId(int sId) { this.sId = sId; } public String getsName() { return sName; } public void setsName(String sName) { this.sName = sName; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } } ``` Student.test.java ``` import java.util.Date; import org.hibernate.*; import org.hibernate.cfg.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class StudentTest { private SessionFactory sessionFactory; private Session session; private Transaction transaction; @Before public void Init() { // 1.加载配置文件 Configuration configuration = new Configuration().configure(); // 2.创建Session工厂 SessionFactory factory = configuration.buildSessionFactory(); // 3.创建Session对象 Session session = factory.openSession(); // 4.开启事务 transaction = session.beginTransaction(); } @Test public void testSaveStudents() { //生成对象 Student student=new Student(1,"张三丰","男",new Date(),"武当山"); //保存对象进数据库 session.save(student); } @After public void destory() { //提交事务 transaction.commit(); //关闭session会话 session.close(); //关闭sessionFactory会话工厂 sessionFactory.close(); } } ``` Student.hbm.xml ``` <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated Apr 21, 2018 5:32:53 PM by Hibernate Tools 3.5.0.Final --> <hibernate-mapping> <class name="Student" table="STUDENT"> <id name="sId" type="int" access="field"> <column name="SID" /> <generator class="assigned" /> </id> <property name="sName" type="java.lang.String" access="field"> <column name="SNAME" /> </property> <property name="gender" type="java.lang.String"> <column name="GENDER" /> </property> <property name="birthday" type="java.util.Date"> <column name="BIRTHDAY" /> </property> <property name="address" type="java.lang.String"> <column name="ADDRESS" /> </property> </class> </hibernate-mapping> ``` Navicat中显示,仅生成了表。 ![图片说明](https://img-ask.csdn.net/upload/201804/23/1524475414_34908.png)
Hibernate4 org.hibernate.QueryException异常问题
各位大侠好,项目一直报错"org.hibernate.QueryException: could not resolve property: u_phone of: com.wanshang.po.Users",我仔细检查po类和映射文件,也没发现错误,请问各位大侠,这个问题是哪里错了?下面是各配置文件: ## Users.java ``` public class Users { private int id; private String name; private String phone; private String password; private String paypassword = "*"; private String usertype = "customer"; private float point = 0; public Users(){} public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getPaypassword() { return paypassword; } public void setPaypassword(String paypassword) { this.paypassword = paypassword; } public String getUsertype() { return usertype; } public void setUsertype(String usertype) { this.usertype = usertype; } public float getPoint() { return point; } public void setPoint(float point) { this.point = point; } } ``` ## Users.hbm.xml ``` <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.wanshang.po.Users" table="usersInfo"> <!-- 用户编号 --> <id name="id" column="u_id"> <generator class="identity" /> </id> <!-- 用户姓名 --> <property name="name" column="u_name" /> <!-- 用户手机 --> <property name="phone" column="u_phone" /> <!-- 用户密码 --> <property name="password" column="u_password" /> <!-- 用户支付密码 --> <property name="paypassword" column="u_paypassword" /> <!-- 用户类型 --> <property name="usertype" column="u_usertype" /> <!-- 用户积分 --> <property name="point" column="u_point" /> </class> </hibernate-mapping> ``` ## hibernate.cfg.xml ``` <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="myeclipse.connection.profile">mysql</property> <!-- 数据库方言 --> <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <!-- 数据库驱动 --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <!-- 数据库链接 --> <property name="connection.url">jdbc:mysql://127.0.0.1:3306/wanshang</property> <!-- 数据库用户名 --> <property name="connection.username">root</property> <!-- 数据库密码 --> <property name="connection.password"></property> <!-- 数据库连接池最大连接数 --> <property name="connection.pool_size">2000</property> <!-- 自动建表 --> <property name="hbm2ddl.auto">update</property> <!-- 打印SQL语句 --> <property name="show_sql">true</property> <!-- 映射 --> <mapping resource="com/wanshang/po/Users.hbm.xml" /> </session-factory> </hibernate-configuration> ``` ## 报错时经常会指向这个方法,代码如下: ``` /*通过字段集合查找*/ public Users findByMap(Map<String, String> params) { // TODO Users users = new Users(); //生成Session实例 Session session = HibernateUtil.getSession(); try{ Criteria criteria = session.createCriteria(Users.class); //遍历Map Set<String> key = params.keySet(); for(Iterator it = key.iterator();it.hasNext();){ String k = (String) it.next(); //保存key criteria.add(Restrictions.eq(k, params.get(k)));//eq是等于,gt是大于,lt是小于,or是或 System.out.println(k+":"+params.get(k)); } users = (Users) criteria.list().get(0); }catch(Exception e){ e.printStackTrace(); }finally{ //关闭Session实例 HibernateUtil.closeSession(session); return users; } } ``` ## 下面是数据库截图: ![图片说明](https://img-ask.csdn.net/upload/201610/21/1477037855_873577.jpg)
数据库没加唯一约束的时候,代码不报错,加上之后验证的时候,可以根据异常简单的try catch处理吗
ERROR 2015-12-02 11:57:55,110 [http-bio-8080-exec-20](JDBCExceptionReporter.java:78) - ORA-00001: 违反唯一约束条件 (SCOTT.SYS_C0011574) ERROR 2015-12-02 11:57:55,110 [http-bio-8080-exec-20](JDBCExceptionReporter.java:78) - ORA-00001: 违反唯一约束条件 (SCOTT.SYS_C0011574) ERROR 2015-12-02 11:57:55,110 [http-bio-8080-exec-20](AbstractFlushingEventListener.java:301) - Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:237) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141) try catch语句是这样的 try { bankBManager.addBankBEntity(bankB); request.setAttribute("jsons", "{\"success\":true,\"msg\":\"保存成功\"}"); } catch (Exception e) { request.setAttribute("jsons", "{\"success\":true,\"msg\":\"数据重复,请重新输入\"}"); }
hibernate3 的多对一的外键更新问题!
[code="ruby"] public class SysModel extends BaseEntity<SysModel> { @ManyToOne(cascade = { CascadeType.MERGE }) @JoinColumn(name = "PARENT_ID") private SysModel sysModel; ....... } [/code] 映射文件大概如此, 有一个自关联字段。 在操作的时候,遇到一个问题,当此字段为 null 的时候,我可以保存,但是不能更新,报错: Hibernate: update SYS_MODEL set DELETE_FLAG=?, MODEL_NAME=?, ORDER_ID=?, remark=?, PARENT_ID=?, url=?, version=? where id=? 2008-09-10 09:55:31,906 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - <Could not synchronize database state with session> org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.sctt.system.sys.model.bean.SysModel at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:397) at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78) 也就是说,PARENT_ID=? 为 NULL 。我基本知道错误原因。 但是,我的本条数据,确实 没有外键呀, sysModel = null; 如何才能更新 这样的数据呢?往高人回答。
hibernate 求各位大神 帮忙看一下
我做的一个Hibernate 一对多 多对一的 保存和读取操作 保存 没问题 但是 读取那老是提示 内存溢出 下面是 实体类 Department 类 有setter 和getter 方法 private Integer id; private String name; private Set<Employee> employees=new HashSet<Employee>(); public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Set<Employee> getEmployees() { return employees; } public void setEmployees(Set<Employee> employees) { this.employees = employees; } Emloyee 类 有setter 和getter 方法 private Integer id; private String name; private Department department; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Department getDepartment() { return department; } public void setDepartment(Department department) { this.department = department; } 下面是映射类 Department.hbm.xml <hibernate-mapping package="org.xxf.OneToManyA"> <class name="Department" table="department"> <id name="id"> <generator class="native"/> </id> <property name="name" type="string" column="name" /> <set name="employees"> <key column="departmentId"></key> <one-to-many class="Employee"/> </set> </class> </hibernate-mapping> Employee.hbm.xml <hibernate-mapping package="org.xxf.OneToManyA"> <class name="Employee" table="employee"> <id name="id"> <generator class="native" /> </id> <property name="name" type="string" column="name" /> <many-to-one name="department" class="Department" column="departmentId"></many-to-one> </class> </hibernate-mapping> 下面是测试类 private static SessionFactory sessionFactory; static{ sessionFactory=new Configuration()// .configure()// .buildSessionFactory(); } @Test public void testget() throws Exception{ Session session=sessionFactory.openSession(); session.beginTransaction(); Department department=(Department) session.get(Department.class, 1); System.out.println(department); System.out.println(department.getEmployees()); session.getTransaction().commit(); session.close(); } hibernate.cfg.xml <hibernate-configuration> <session-factory> <!-- 数据库基本配置信息 --> <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql:///htest</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <!-- 数据库其他相关配置 --> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resource="org/xxf/OneToManyA/Department.hbm.xml"/> <mapping resource="org/xxf/OneToManyA/Employee.hbm.xml"/> </session-factory> </hibernate-configuration> 测试后 它就老提示 我内存溢出 java.lang.StackOverflowError at java.lang.Integer.toString(Integer.java:305) at java.lang.Integer.toString(Integer.java:116) at java.lang.String.valueOf(String.java:2932) at java.lang.Integer.toString(Integer.java:682) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:115) at org.xxf.OneToManyA.Employee.toString(Employee.java:13) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:115) at java.util.AbstractCollection.toString(AbstractCollection.java:422) at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:327) 往下 就一直重复出现错误 别人用一样的代码 测试就没问题 我就老报错 求各位大神帮指导一下
用hibernate的uuid注解生成主键, save时提示id出错
使用hibernate uuid注解 自动生成id值,在students和courses多对多的级联保存时, id保存出错 报错代码如下 ``` log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly. Hibernate: insert into students (sname, id) values (?, ?) Hibernate: insert into courses (cname, id) values (?, ?) Hibernate: insert into courses (cname, id) values (?, ?) Hibernate: insert into students_courses (sid, cid) values (?, ?) Hibernate: insert into students_courses (sid, cid) values (?, ?) org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:171) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137) at com.caidi.Test.TestManyToManyEach.test01(TestManyToManyEach.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:292) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.sql.BatchUpdateException: Field 'id' doesn't have a default value at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1693) at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1108) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268) ... 31 more ``` 1. Students类 ``` package com.caidi.beans; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name="students") public class Students { @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uuid.hex") @Column(name="id") private String id; @Column(name="sname") private String sname; @ManyToMany @Cascade(value={CascadeType.SAVE_UPDATE}) @JoinTable(name="students_courses",joinColumns={@JoinColumn(name="sid",referencedColumnName="id")},inverseJoinColumns={@JoinColumn(name="cid",referencedColumnName="id")}) private List<Courses> courses; public Students() { super(); } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getSname() { return sname; } public void setSname(String sname) { this.sname = sname; } public List<Courses> getCourses() { return courses; } public void setCourses(List<Courses> courses) { this.courses = courses; } } ``` 2. Courses类 ``` package com.caidi.beans; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.Table; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name="courses") public class Courses { @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uuid.hex") @Column(name="id") private String id; @Column(name="cname") private String cname; @ManyToMany(mappedBy="courses")//ManyToMany默认lazy加载 @Cascade(value={CascadeType.SAVE_UPDATE}) private List<Students> students; public Courses() { super(); } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getCname() { return cname; } public void setCname(String cname) { this.cname = cname; } public List<Students> getStudents() { return students; } public void setStudents(List<Students> students) { this.students = students; } } ``` 3. Students_Courses.java ``` package com.caidi.beans; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name="students_courses") public class Students_Courses { private String id; @Column(name="sid") private String sid; @Column(name="cid") private String cid; public Students_Courses() { super(); } @Id @GeneratedValue(generator="system-uuid") @GenericGenerator(name="system-uuid", strategy = "uuid.hex") @Column(name="id") public String getId() { return id; } public void setId(String id) { this.id = id; } public String getSid() { return sid; } public void setSid(String sid) { this.sid = sid; } public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } } ``` 4. 测试代码 ``` package com.caidi.Test; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import org.junit.Test; import com.caidi.beans.Courses; import com.caidi.beans.Students; import com.caidi.utils.HibernateTools; public class TestManyToManyEach { @Test public void test01(){ Session session = HibernateTools.getSession(); //开启事物 Transaction tr = session.beginTransaction(); try{ Courses c1 = new Courses();Courses c2 = new Courses(); c1.setCname("数学课"); c2.setCname("语文课"); List list1 = new ArrayList(); list1.add(c1);list1.add(c2); Students s1 = new Students(); s1.setSname("小明"); s1.setCourses(list1); session.save(s1); tr.commit(); System.out.println("finsh"); }catch(Exception e){ tr.rollback(); e.printStackTrace(); }finally{ if(session.isOpen() ==true){ session.close(); } } } } ``` mysql数据库 ![课程表courses](https://img-ask.csdn.net/upload/201802/26/1519657880_228265.png) ![学生表students](https://img-ask.csdn.net/upload/201802/26/1519657916_358265.png) ![中间表students_courses](https://img-ask.csdn.net/upload/201802/26/1519657943_981379.png)
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小人工智障。 思路可以运用在不同地方,主要介绍的是思路。
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
阿里面试官问我:如何设计秒杀系统?我的回答让他比起大拇指
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图和个人联系方式,欢迎Star和指教 前言 Redis在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在Redis的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了...
C语言魔塔游戏
很早就很想写这个,今天终于写完了。 游戏截图: 编译环境: VS2017 游戏需要一些图片,如果有想要的或者对游戏有什么看法的可以加我的QQ 2985486630 讨论,如果暂时没有回应,可以在博客下方留言,到时候我会看到。 下面我来介绍一下游戏的主要功能和实现方式 首先是玩家的定义,使用结构体,这个名字是可以自己改变的 struct gamerole { char n...
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
Android性能优化(4):UI渲染机制以及优化
文章目录1. 渲染机制分析1.1 渲染机制1.2 卡顿现象1.3 内存抖动2. 渲染优化方式2.1 过度绘制优化2.1.1 Show GPU overdraw2.1.2 Profile GPU Rendering2.2 卡顿优化2.2.1 SysTrace2.2.2 TraceView 在从Android 6.0源码的角度剖析View的绘制原理一文中,我们了解到View的绘制流程有三个步骤,即m...
微服务中的Kafka与Micronaut
今天,我们将通过Apache Kafka主题构建一些彼此异步通信的微服务。我们使用Micronaut框架,它为与Kafka集成提供专门的库。让我们简要介绍一下示例系统的体系结构。我们有四个微型服务:订单服务,行程服务,司机服务和乘客服务。这些应用程序的实现非常简单。它们都有内存存储,并连接到同一个Kafka实例。 我们系统的主要目标是为客户安排行程。订单服务应用程序还充当网关。它接收来自客户的请求...
致 Python 初学者们!
作者| 许向武 责编 | 屠敏 出品 | CSDN 博客 前言 在 Python 进阶的过程中,相信很多同学应该大致上学习了很多 Python 的基础知识,也正在努力成长。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 Python 这门编程语言,从2009年开始单一使用 Python 应对所有的开发工作,直至今...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观...
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外...
字节跳动面试官这样问消息队列:分布式事务、重复消费、顺序消费,我整理了一下
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式和人才交流群,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip installselenium -ihttps://pypi.tuna.tsinghua.edu.cn/simple/ ...
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca...
SpringBoot2.x系列教程(三十六)SpringBoot之Tomcat配置
Spring Boot默认内嵌的Tomcat为Servlet容器,关于Tomcat的所有属性都在ServerProperties配置类中。同时,也可以实现一些接口来自定义内嵌Servlet容器和内嵌Tomcat等的配置。 关于此配置,网络上有大量的资料,但都是基于SpringBoot1.5.x版本,并不适合当前最新版本。本文将带大家了解一下最新版本的使用。 ServerProperties的部分源...
Python绘图,圣诞树,花,爱心 | Turtle篇
每周每日,分享Python实战代码,入门资料,进阶资料,基础语法,爬虫,数据分析,web网站,机器学习,深度学习等等。 公众号回复【进群】沟通交流吧,QQ扫码进群学习吧 微信群 QQ群 1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle()...
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东...
破14亿,Python分析我国存在哪些人口危机!
一、背景 二、爬取数据 三、数据分析 1、总人口 2、男女人口比例 3、人口城镇化 4、人口增长率 5、人口老化(抚养比) 6、各省人口 7、世界人口 四、遇到的问题 遇到的问题 1、数据分页,需要获取从1949-2018年数据,观察到有近20年参数:LAST20,由此推测获取近70年的参数可设置为:LAST70 2、2019年数据没有放上去,可以手动添加上去 3、将数据进行 行列转换 4、列名...
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o...
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ...... ...
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。 再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。 下文是原回答,希望能对你能有所启发。 如果我说,这个世界上人真的分三六九等,...
2020年全新Java学习路线图,含配套视频,学完即为中级Java程序员!!
新的一年来临,突如其来的疫情打破了平静的生活! 在家的你是否很无聊,如果无聊就来学习吧! 世上只有一种投资只赚不赔,那就是学习!!! 传智播客于2020年升级了Java学习线路图,硬核升级,免费放送! 学完你就是中级程序员,能更快一步找到工作! 一、Java基础 JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。 在Java基础板块中有6个子模块的学...
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合...
爬取薅羊毛网站百度云资源
这是疫情期间无聊做的爬虫, 去获取暂时用不上的教程 import threading import time import pandas as pd import requests import re from threading import Thread, Lock # import urllib.request as request # req=urllib.request.Requ...
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名...
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计...
HTML5适合的情人节礼物有纪念日期功能
前言 利用HTML5,css,js实现爱心树 以及 纪念日期的功能 网页有播放音乐功能 以及打字倾诉感情的画面,非常适合情人节送给女朋友 具体的HTML代码 具体只要修改代码里面的男某某和女某某 文字段也可自行修改,还有代码下半部分的JS代码需要修改一下起始日期 注意月份为0~11月 也就是月份需要减一。 当然只有一部分HTML和JS代码不够运行的,文章最下面还附加了完整代码的下载地址 &lt;!...
相关热词 c#导入fbx c#中屏蔽键盘某个键 c#正态概率密度 c#和数据库登陆界面设计 c# 高斯消去法 c# codedom c#读取cad文件文本 c# 控制全局鼠标移动 c# temp 目录 bytes初始化 c#
立即提问