How to get NHibernate to work with PK values generated by a trigger?

time to read 1 min | 99 words

Well, the correct answer is to use a <generator type="select">, but that hasn't been ported to NHinbernate yet, so a quick & dirty solution may be this piece of code, that I just wrote in Notepad and I have no idea if it really works :-)

public class MyOracleDialect : OracleDialect
{
	public override bool SupportsIdentityColumns
	{
		get
		{
			return true;
		}
	}
	 
	public override string GetIdentitySelectString(string identityColumn, string tableName)
	{
		return "select mySequnece_"+tableName+".currnetValue() from dual; ";
	}
}