为了账号安全,请及时绑定邮箱和手机立即绑定

添加信息问题

九月 16, 2016 2:10:57 下午 org.hibernate.annotations.common.Version <clinit>

INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}

九月 16, 2016 2:10:57 下午 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {4.2.4.Final}

九月 16, 2016 2:10:57 下午 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

九月 16, 2016 2:10:57 下午 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist

九月 16, 2016 2:10:57 下午 org.hibernate.cfg.Configuration configure

INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml

九月 16, 2016 2:10:57 下午 org.hibernate.cfg.Configuration getConfigurationInputStream

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml

九月 16, 2016 2:10:58 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: Grade.hbm.xml

九月 16, 2016 2:10:58 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity

WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

九月 16, 2016 2:10:58 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: Student.hbm.xml

九月 16, 2016 2:10:58 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity

WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!

九月 16, 2016 2:10:58 下午 org.hibernate.cfg.Configuration doConfigure

INFO: HHH000041: Configured SessionFactory: null

九月 16, 2016 2:10:58 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)

九月 16, 2016 2:10:58 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000115: Hibernate connection pool size: 20

九月 16, 2016 2:10:58 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000006: Autocommit mode: false

九月 16, 2016 2:10:58 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql:///abe?useUnicode=true&characterEncoding=utf8]

九月 16, 2016 2:10:58 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000046: Connection properties: {user=root, password=****}

九月 16, 2016 2:10:58 下午 org.hibernate.dialect.Dialect <init>

INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect

九月 16, 2016 2:10:58 下午 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation

INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4

九月 16, 2016 2:10:58 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService

INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)

九月 16, 2016 2:10:58 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>

INFO: HHH000397: Using ASTQueryTranslatorFactory

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000228: Running hbm2ddl schema update

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000102: Fetching database metadata

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000396: Updating schema

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000261: Table found: abe.grade

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000037: Columns: [gdesc, gid, gname]

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000108: Foreign keys: []

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000126: Indexes: [primary]

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000261: Table found: abe.student

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000037: Columns: [gid, sname, sex, sanme, sid]

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000108: Foreign keys: [fk_student_gid]

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000126: Indexes: [fk_student_gid, primary]

九月 16, 2016 2:10:59 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000232: Schema update complete

Hibernate: 

    select

        max(SID) 

    from

        STUDENT

Hibernate: 

    select

        max(GID) 

    from

        GRADE

九月 16, 2016 2:10:59 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions

WARN: SQL Error: 1364, SQLState: HY000

九月 16, 2016 2:10:59 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions

ERROR: Field 'sname' doesn't have a default value

Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute statement

at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)

at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)

at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:136)

at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:58)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3067)

at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3509)

at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:88)

at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:377)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:369)

at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:286)

at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339)

at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)

at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234)

at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)

at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)

at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)

at com.abe.test.Test.add(Test.java:32)

at com.abe.test.Test.main(Test.java:13)

Caused by: java.sql.SQLException: Field 'sname' 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:133)

... 15 more

Hibernate: 

    insert 

    into

        STUDENT

        (SANME, SEX, SID) 

    values

        (?, ?, ?)


正在回答

2 回答

这个怎么处理?我要给SANME添加默认值?


0 回复 有任何疑惑可以回复我~

错误:字段'SNAME'没有默认值

异常线程“main”org.hibernate.exception.GenericJDBCException:无法执行语句


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Hibernate初探之一对多映射
  • 参与学习       42171    人
  • 解答问题       295    个

Hibernate中一对多关联映射配置,以及cascade和inverse属性作用

进入课程

添加信息问题

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信