Methods Summary |
---|
protected void | addDiscriminatorToSelect(org.hibernate.sql.SelectFragment select, java.lang.String name, java.lang.String suffix)
select.addColumn( name, getDiscriminatorColumnName(), getDiscriminatorAlias() );
|
public java.lang.String | filterFragment(java.lang.String name)
return hasWhere() ?
" and " + getSQLWhereString(name) :
"";
|
public java.lang.String | fromTableFragment(java.lang.String name)
return getTableName() + ' " + name;
|
protected java.lang.String | generateSelectString(org.hibernate.LockMode lockMode)Generate the SQL that selects a row by id
SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
.setLockMode(lockMode)
.setTableName( getTableName() )
.addColumns( getIdentifierColumnNames() )
.addColumns(
getSubclassColumnClosure(),
getSubclassColumnAliasClosure(),
getSubclassColumnLazyiness()
)
.addColumns(
getSubclassFormulaClosure(),
getSubclassFormulaAliasClosure(),
getSubclassFormulaLazyiness()
);
//TODO: include the rowids!!!!
if ( hasSubclasses() ) {
if ( isDiscriminatorFormula() ) {
select.addColumn( getDiscriminatorFormula(), getDiscriminatorAlias() );
}
else {
select.addColumn( getDiscriminatorColumnName(), getDiscriminatorAlias() );
}
}
if ( getFactory().getSettings().isCommentsEnabled() ) {
select.setComment( "load " + getEntityName() );
}
return select.addCondition( getIdentifierColumnNames(), "=?" ).toStatementString();
|
protected java.lang.String | generateSubquery(org.hibernate.mapping.PersistentClass model, org.hibernate.engine.Mapping mapping)
Dialect dialect = getFactory().getDialect();
Settings settings = getFactory().getSettings();
if ( !model.hasSubclasses() ) {
return model.getTable().getQualifiedName(
dialect,
settings.getDefaultCatalogName(),
settings.getDefaultSchemaName()
);
}
HashSet columns = new HashSet();
Iterator titer = model.getSubclassTableClosureIterator();
while ( titer.hasNext() ) {
Table table = (Table) titer.next();
if ( !table.isAbstractUnionTable() ) {
Iterator citer = table.getColumnIterator();
while ( citer.hasNext() ) columns.add( citer.next() );
}
}
StringBuffer buf = new StringBuffer()
.append("( ");
Iterator siter = new JoinedIterator(
new SingletonIterator(model),
model.getSubclassIterator()
);
while ( siter.hasNext() ) {
PersistentClass clazz = (PersistentClass) siter.next();
Table table = clazz.getTable();
if ( !table.isAbstractUnionTable() ) {
//TODO: move to .sql package!!
buf.append("select ");
Iterator citer = columns.iterator();
while ( citer.hasNext() ) {
Column col = (Column) citer.next();
if ( !table.containsColumn(col) ) {
int sqlType = col.getSqlTypeCode(mapping);
buf.append( dialect.getSelectClauseNullString(sqlType) )
.append(" as ");
}
buf.append( col.getName() );
buf.append(", ");
}
buf.append( clazz.getSubclassId() )
.append(" as clazz_");
buf.append(" from ")
.append( table.getQualifiedName(
dialect,
settings.getDefaultCatalogName(),
settings.getDefaultSchemaName()
) );
buf.append(" union ");
if ( dialect.supportsUnionAll() ) {
buf.append("all ");
}
}
}
if ( buf.length() > 2 ) {
//chop the last union (all)
buf.setLength( buf.length() - ( dialect.supportsUnionAll() ? 11 : 7 ) );
}
return buf.append(" )").toString();
|
public java.lang.String[] | getConstraintOrderedTableNameClosure()
return constraintOrderedTableNames;
|
public java.lang.String[][] | getContraintOrderedTableKeyColumnClosure()
return constraintOrderedKeyColumnNames;
|
protected java.lang.String | getDiscriminatorFormula()
return null;
|
public java.lang.String | getDiscriminatorSQLValue()
return discriminatorSQLValue;
|
public org.hibernate.type.Type | getDiscriminatorType()
return Hibernate.INTEGER;
|
protected java.lang.String[] | getKeyColumns(int j)
return getIdentifierColumnNames();
|
public java.io.Serializable[] | getPropertySpaces()
return spaces;
|
public java.lang.String | getPropertyTableName(java.lang.String propertyName)
//TODO: check this....
return getTableName();
|
protected int[] | getPropertyTableNumbers()
return new int[ getPropertySpan() ];
|
protected int[] | getPropertyTableNumbersInSelect()
return new int[ getPropertySpan() ];
|
public java.io.Serializable[] | getQuerySpaces()
return subclassSpaces;
|
public java.lang.String[] | getSubclassClosure()
return subclassClosure;
|
protected int[] | getSubclassColumnTableNumberClosure()
return new int[ getSubclassColumnClosure().length ];
|
public java.lang.String | getSubclassForDiscriminatorValue(java.lang.Object value)
return (String) subclassByDiscriminatorValue.get(value);
|
protected int[] | getSubclassFormulaTableNumberClosure()
return new int[ getSubclassFormulaClosure().length ];
|
public java.lang.String | getSubclassPropertyTableName(int i)
return getTableName();//ie. the subquery! yuck!
|
protected int | getSubclassPropertyTableNumber(int i)
return 0;
|
public int | getSubclassPropertyTableNumber(java.lang.String propertyName)
return 0;
|
protected java.lang.String[] | getSubclassTableKeyColumns(int j)
if (j!=0) throw new AssertionFailure("only one table");
return getIdentifierColumnNames();
|
public java.lang.String | getSubclassTableName(int j)
if (j!=0) throw new AssertionFailure("only one table");
return tableName;
|
public int | getSubclassTableSpan()
return 1;
|
protected boolean[] | getTableHasColumns()
return new boolean[] { true };
|
protected java.lang.String | getTableName(int j)
return tableName;
|
public java.lang.String | getTableName()
return subquery;
|
public int | getTableSpan()
return 1;
|
protected boolean | isClassOrSuperclassTable(int j)
if (j!=0) throw new AssertionFailure("only one table");
return true;
|
protected boolean | isDiscriminatorFormula()
return false;
|
public boolean | isMultiTable()
// This could also just be true all the time...
return isAbstract() || hasSubclasses();
|
protected boolean | isPropertyOfTable(int property, int j)
return true;
|
protected boolean | isTableCascadeDeleteEnabled(int j)
return false;
|