Hello Paul,
I thank you very much for your mail. I downloaded a newer version of FNH.
Below is the convention class which I wrote to apply to all entities whose ID are of the UINT type.
Convention Code
public class UIntPrimaryKeyNamingConvention : IIdConvention, IIdConventionAcceptance
{
public void Apply(IIdentityInstance id)
{
id.CustomSqlType("MEDIUMINT UNSIGNED");
}
public void Accept(IAcceptanceCriteria<IIdentityInspector> criteria)
{
criteria.Expect(i => i.Type == typeof(uint));
}
}
Applying this to create my database throws exceptions. Looking closely at the exceptions, I noticed the exceptions are being thrown when REFERENCES to such entities are being applied.
Please, what can be done?
Thanking you in anticipation.
Isaac
Details of the exception thrown can be seen below:
alter table `ScratchFail`
add index (StudentEnrolId),
add constraint FK19A86696AF8F2A12
foreign key (StudentEnrolId)
references `StudentEnrol` (StudentEnrolId)
System.TypeInitializationException: The type initializer for 'Nested' threw an exception. ---> NHibernate.HibernateException: Can't create table 'netquepgcurrent.#sql-f0_27' (errno
: 150) ---> MySql.Data.MySqlClient.MySqlException: Can't create table 'netquepgcurrent.#sql-f0_27' (errno: 150)
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult()
at MySql.Data.MySqlClient.ResultSet.NextResult()
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean throwOnError, TextWriter exportOutput, IDbCommand statement, String sql)
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean justDrop, IDbConnection connection, TextWriter exportOutput)
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean justDrop)
--- End of inner exception stack trace ---
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean justDrop)
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, Boolean export, Boolean justDrop)
at netquepgcurrent.NHH..ctor() in E:\source.code\Visual Studio 2008\Projects\PG\@College\College Tools\netquepgcurrent\NHH.cs:line 40
at netquepgcurrent.NHH.Nested..cctor() in E:\source.code\Visual Studio 2008\Projects\PG\@College\College Tools\netquepgcurrent\NHH.cs:line 89
--- End of inner exception stack trace ---
at netquepgcurrent.NHH.get_Instance() in E:\source.code\Visual Studio 2008\Projects\PG\@College\College Tools\netquepgcurrent\NHH.cs:line 66
at netquepgcurrent.NHH.Init() in E:\source.code\Visual Studio 2008\Projects\PG\@College\College Tools\netquepgcurrent\NHH.cs:line 71
at ConsoleApplication4_Conversion.Program.Run() in E:\source.code\Visual Studio 2008\Projects\PG\@College\College Tools\ConsoleApplication4-Conversion\Program.cs:line 41
at ConsoleApplication4_Conversion.Program.Main(String[] args) in E:\source.code\Visual Studio 2008\Projects\PG\@College\College Tools\ConsoleApplication4-Conversion\Program.cs:line 24