private SqlString GenerateLockString() { ISessionFactoryImplementor factory = lockable.Factory; SqlSimpleSelectBuilder select = new SqlSimpleSelectBuilder(factory.Dialect, factory) .SetLockMode(lockMode) .SetTableName(lockable.RootTableName) .AddColumn(lockable.RootTableIdentifierColumnNames[0]) .SetIdentityColumn(lockable.RootTableIdentifierColumnNames, lockable.IdentifierType); if (lockable.IsVersioned) { select.SetVersionColumn(new string[] { lockable.VersionColumnName }, lockable.VersionType); } if (factory.Settings.IsCommentsEnabled) { select.SetComment(lockMode + " lock " + lockable.EntityName); } return select.ToSqlString(); }
/// <summary> /// Generate the SQL that selects the version number by id /// </summary> protected SqlString GenerateSelectVersionString() { SqlSimpleSelectBuilder builder = new SqlSimpleSelectBuilder(Factory.Dialect, factory) .SetTableName(VersionedTableName); if (IsVersioned) builder.AddColumn(versionColumnName); else builder.AddColumns(rootTableKeyColumnNames); if (Factory.Settings.IsCommentsEnabled) { builder.SetComment("get version " + EntityName); } return builder.AddWhereFragment(rootTableKeyColumnNames, IdentifierType, " = ").ToSqlString(); }
/// <summary> Generate the SQL that selects a row by id</summary> protected internal virtual SqlString GenerateSelectString(LockMode lockMode) { SqlSimpleSelectBuilder select = new SqlSimpleSelectBuilder(Factory.Dialect, Factory) .SetLockMode(lockMode) .SetTableName(TableName) .AddColumns(IdentifierColumnNames) .AddColumns(SubclassColumnClosure, SubclassColumnAliasClosure, SubclassColumnLazyiness) .AddColumns(SubclassFormulaClosure, SubclassFormulaAliasClosure, SubclassFormulaLazyiness); //TODO: include the rowids!!!! if (HasSubclasses) { if (IsDiscriminatorFormula) { select.AddColumn(DiscriminatorFormula, DiscriminatorAlias); } else { select.AddColumn(DiscriminatorColumnName, DiscriminatorAlias); } } if (Factory.Settings.IsCommentsEnabled) { select.SetComment("load " + EntityName); } return select.AddWhereFragment(IdentifierColumnNames, IdentifierType, "=").ToSqlString(); }