私はこの質問を見ました
NHibernateHiLo-すべてのエンティティに1つのテーブル
だから私は読んだ
http://daniel.wertheim.se/2011/03/08/nhibernate-custom-id-generator/
そして私は休止状態でそれをやろうとしました。hibernateはプロパティハッシュマップの「where」キーをチェックしないため、configure関数を自分でオーバーライドしようとしましたが、値を読み取ったり更新したりできません。
これに対する準備ができている解決策はありますか?私のコードは以下の通りです。
@Override
public void configure(Type type, Properties params, Dialect dialect)
{
tableName="myTableNameForHiloValues"; //hardcoded
columnName="NextHiValue";//the column that holds the next hi value
String schemaName = params.getProperty(SCHEMA);
String catalogName = params.getProperty(CATALOG);
tableName = Table.qualify( catalogName, schemaName, tableName );
query = "select " + columnName +
" from " //+ dialect.appendLockHint(LockMode.UPGRADE, tableName) +
dialect.getForUpdateString() +
" where EntityName='"+params.getProperty("target_table")+"'"
//here i give the entity that i want to use
;
update = "update " + tableName +
" set " + columnName + " = ? "+
" where " + columnName + " = ?"+
" and EntityName='"+params.getProperty("target_table")+"'"
;
}
myTableNameForHiloValuesテーブルの構造は次のようになります。
EntityName | NextHiValue