在跟老师一起做PhotonServeR的登录教程的时候出了个问题找不到解决原因,我在客户端点登录之后LOG日志里面 有一个报错看不懂。
我理解是不是哪里调用了一个Nhibernate的ADD方法,而USERNAME是空,但是我找不到哪里调用了这个。。
报错如下:
2017-06-25 14:23:47,503 [10] INFO NHibernate.Impl.SessionFactoryImpl - building session factory
2017-06-25 14:23:48,248 [10] INFO NHibernate.Impl.SessionFactoryObjectFactory - no name configured
2017-06-25 14:23:48,352 [10] INFO NHibernate.Loader.Loader - SELECT this_.id as id1_0_0_, this_.username as userna2_0_0_, this_.password as passwo3_0_0_, this_.registerdate as regist4_0_0_ FROM users this_ WHERE this_.username is null
2017-06-25 14:23:48,520 [10] ERROR NHibernate.AdoNet.AbstractBatcher - Could not execute query: INSERT INTO users (username, password, registerdate) VALUES (?p0, ?p1, ?p2);SELECT LAST_INSERT_ID()
MySql.Data.MySqlClient.MySqlException (0x80004005): Column 'username' cannot be null
在 MySql.Data.MySqlClient.MySqlStream.ReadPacket()
在 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
在 MySql.Data.MySqlClient.MySqlDataReader.NextResult()
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
在 NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
2017-06-25 14:23:48,528 [10] WARN NHibernate.Util.ADOExceptionReporter - MySql.Data.MySqlClient.MySqlException (0x80004005): Column 'username' cannot be null
在 MySql.Data.MySqlClient.MySqlStream.ReadPacket()
在 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
在 MySql.Data.MySqlClient.MySqlDataReader.NextResult()
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
在 NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
在 NHibernate.Id.IdentityGenerator.InsertSelectDelegate.ExecuteAndExtract(IDbCommand insert, ISessionImplementor session)
在 NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder)
2017-06-25 14:23:48,529 [10] ERROR NHibernate.Util.ADOExceptionReporter - Column 'username' cannot be null
2017-06-25 14:23:48,535 [10] ERROR Photon.SocketServer.PeerBase - exception during handling of data.Peer:T:ClientPeer,ConnId:0,ip:127.0.0.1:60910, Data: F3-02-01-00-02-01-69-00-00-00-64-02-73-00-04-65-72-72-72,
Exception:NHibernate.Exceptions.GenericADOException: could not insert: [SurviveServer.Model.Users][SQL: INSERT INTO users (username, password, registerdate) VALUES (?, ?, ?);SELECT LAST_INSERT_ID()] ---> MySql.Data.MySqlClient.MySqlException: Column 'username' cannot be null
在 MySql.Data.MySqlClient.MySqlStream.ReadPacket()
在 MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
在 MySql.Data.MySqlClient.MySqlDataReader.NextResult()
在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
在 NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
在 NHibernate.Id.IdentityGenerator.InsertSelectDelegate.ExecuteAndExtract(IDbCommand insert, ISessionImplementor session)
在 NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder)
--- 内部异常堆栈跟踪的结尾 ---
2017-09-03 15:51:34,884 [11] ERROR Photon.SocketServer.PeerBase [(null)] - NHibernate.Exceptions.GenericADOException: could not insert: [TaidouCommon.Model.Role][SQL: INSERT INTO role (name, level, isman, userid) VALUES (?, ?, ?, ?)] ---> MySql.Data.MySqlClient.MySqlException: Cannot add or update a child row: a foreign key constraint fails (`taidouserver`.`role`, CONSTRAINT `fk_userid` FOREIGN KEY (`userid`) REFERENCES `role` (`Id`))
我做的泰斗破坏神出现这种错误的,是什么原因呢?