For the first time, use hibernate for JUnit testing and report the following error.
Cause: Hibernate helps us manage the primary key, and we don't need to assign a value to the primary key, and the primary key is self-increment. So in the database, the gradual selection should be checked
org.hibernate.exception.GenericJDBCException:could not execute statement
At Org.hibernate.exception.internal.StandardSQLExceptionConverter.convert (standardsqlexceptionconverter.java:47 )
At Org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert (sqlexceptionhelper.java:109)
At Org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert (sqlexceptionhelper.java:95)
At Org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate (resultsetreturnimpl.java:207)
At Org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract (getgeneratedkeysdelegate.java:57)
At Org.hibernate.id.insert.AbstractReturningDelegate.performInsert (abstractreturningdelegate.java:42)
At Org.hibernate.persister.entity.AbstractEntityPersister.insert (abstractentitypersister.java:2792)
At Org.hibernate.persister.entity.AbstractEntityPersister.insert (abstractentitypersister.java:3363)
At Org.hibernate.action.internal.EntityIdentityInsertAction.execute (entityidentityinsertaction.java:81)
At Org.hibernate.engine.spi.ActionQueue.execute (actionqueue.java:597)
At Org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction (actionqueue.java:232)
At Org.hibernate.engine.spi.ActionQueue.addInsertAction (actionqueue.java:213)
At Org.hibernate.engine.spi.ActionQueue.addAction (actionqueue.java:256)
At Org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction (abstractsaveeventlistener.java:317)
At Org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate (Abstractsaveeventlistener.java : 272)
At Org.hibernate.event.internal.AbstractSaveEventListener.performSave (abstractsaveeventlistener.java:178)
At Org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId (Abstractsaveeventlistener.java : 109)
At Org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId ( defaultsaveorupdateeventlistener.java:192)
At Org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId ( DEFAULTSAVEEVENTLISTENER.JAVA:38)
At Org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient ( defaultsaveorupdateeventlistener.java:177)
At Org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate (defaultsaveeventlistener.java:32)
At Org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate ( defaultsaveorupdateeventlistener.java:73)
At Org.hibernate.internal.SessionImpl.fireSave (sessionimpl.java:679)
At Org.hibernate.internal.SessionImpl.save (sessionimpl.java:671)
At Org.hibernate.internal.SessionImpl.save (sessionimpl.java:666)
At Test. Demo1.function (demo1.java:42)
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.SQLException:Field ' CustomerId ' doesn ' t have a default value
At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1055)
At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:956)
At Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:3515)
At Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:3447)
At Com.mysql.jdbc.MysqlIO.sendCommand (mysqlio.java:1951)
At Com.mysql.jdbc.MysqlIO.sqlQueryDirect (mysqlio.java:2101)
At Com.mysql.jdbc.ConnectionImpl.execSQL (connectionimpl.java:2554)
At Com.mysql.jdbc.PreparedStatement.executeInternal (preparedstatement.java:1761)
At Com.mysql.jdbc.PreparedStatement.executeUpdate (preparedstatement.java:2046)
At Com.mysql.jdbc.PreparedStatement.executeUpdate (preparedstatement.java:1964)
At Com.mysql.jdbc.PreparedStatement.executeUpdate (preparedstatement.java:1949)
At Org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate (resultsetreturnimpl.java:204)
... More
Hibernate learning Error Collection-genericjdbcexception:could not execute statement