/// <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, SubclassColumnLaziness) .AddColumns(SubclassFormulaClosure, SubclassFormulaAliasClosure, SubclassFormulaLaziness); //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()); }
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()); }