001: //$Id: Queryable.java 10825 2006-11-16 19:33:19Z steve.ebersole@jboss.com $
002: package org.hibernate.persister.entity;
003:
004: /**
005: * Extends the generic <tt>EntityPersister</tt> contract to add
006: * operations required by the Hibernate Query Language
007: *
008: * @author Gavin King
009: */
010: public interface Queryable extends Loadable, PropertyMapping, Joinable {
011:
012: /**
013: * Is this an abstract class?
014: */
015: public boolean isAbstract();
016:
017: /**
018: * Is this class explicit polymorphism only?
019: */
020: public boolean isExplicitPolymorphism();
021:
022: /**
023: * Get the class that this class is mapped as a subclass of -
024: * not necessarily the direct superclass
025: */
026: public String getMappedSuperclass();
027:
028: /**
029: * Get the discriminator value for this particular concrete subclass,
030: * as a string that may be embedded in a select statement
031: */
032: public String getDiscriminatorSQLValue();
033:
034: /**
035: * Given a query alias and an identifying suffix, render the intentifier select fragment.
036: */
037: public String identifierSelectFragment(String name, String suffix);
038:
039: /**
040: * Given a query alias and an identifying suffix, render the property select fragment.
041: */
042: public String propertySelectFragment(String alias, String suffix,
043: boolean allProperties);
044:
045: /**
046: * Get the names of columns used to persist the identifier
047: */
048: public String[] getIdentifierColumnNames();
049:
050: /**
051: * Is the inheritence hierarchy described by this persister contained across
052: * multiple tables?
053: *
054: * @return True if the inheritence hierarchy is spread across multiple tables; false otherwise.
055: */
056: public boolean isMultiTable();
057:
058: /**
059: * Get the names of all tables used in the hierarchy (up and down) ordered such
060: * that deletes in the given order would not cause contraint violations.
061: *
062: * @return The ordered array of table names.
063: */
064: public String[] getConstraintOrderedTableNameClosure();
065:
066: /**
067: * For each table specified in {@link #getConstraintOrderedTableNameClosure()}, get
068: * the columns that define the key between the various hierarchy classes.
069: * <p/>
070: * The first dimension here corresponds to the table indexes returned in
071: * {@link #getConstraintOrderedTableNameClosure()}.
072: * <p/>
073: * The second dimension should have the same length across all the elements in
074: * the first dimension. If not, that'd be a problem ;)
075: *
076: * @return
077: */
078: public String[][] getContraintOrderedTableKeyColumnClosure();
079:
080: /**
081: * Get the name of the temporary table to be used to (potentially) store id values
082: * when performing bulk update/deletes.
083: *
084: * @return The appropriate temporary table name.
085: */
086: public String getTemporaryIdTableName();
087:
088: /**
089: * Get the appropriate DDL command for generating the temporary table to
090: * be used to (potentially) store id values when performing bulk update/deletes.
091: *
092: * @return The appropriate temporary table creation command.
093: */
094: public String getTemporaryIdTableDDL();
095:
096: /**
097: * Given a property name, determine the number of the table which contains the column
098: * to which this property is mapped.
099: * <p/>
100: * Note that this is <b>not</b> relative to the results from {@link #getConstraintOrderedTableNameClosure()}.
101: * It is relative to the subclass table name closure maintained internal to the persister (yick!).
102: * It is also relative to the indexing used to resolve {@link #getSubclassTableName}...
103: *
104: * @param propertyPath The name of the property.
105: * @return The nunber of the table to which the property is mapped.
106: */
107: public int getSubclassPropertyTableNumber(String propertyPath);
108:
109: /**
110: * Determine whether the given property is declared by our
111: * mapped class, our super class, or one of our subclasses...
112: * <p/>
113: * Note: the method is called 'subclass property...' simply
114: * for consistency sake (e.g. {@link #getSubclassPropertyTableNumber}
115: *
116: * @param propertyPath The property name.
117: * @return The property declarer
118: */
119: public Declarer getSubclassPropertyDeclarer(String propertyPath);
120:
121: /**
122: * Get the name of the table with the given index from the internal
123: * array.
124: *
125: * @param number The index into the internal array.
126: * @return
127: */
128: public String getSubclassTableName(int number);
129:
130: /**
131: * Is the version property included in insert statements?
132: */
133: public boolean isVersionPropertyInsertable();
134:
135: /**
136: * The alias used for any filter conditions (mapped where-fragments or
137: * enabled-filters).
138: * </p>
139: * This may or may not be different from the root alias depending upon the
140: * inheritence mapping strategy.
141: *
142: * @param rootAlias The root alias
143: * @return The alias used for "filter conditions" within the where clause.
144: */
145: public String generateFilterConditionAlias(String rootAlias);
146:
147: public static class Declarer {
148: public static final Declarer CLASS = new Declarer("class");
149: public static final Declarer SUBCLASS = new Declarer("subclass");
150: public static final Declarer SUPERCLASS = new Declarer(
151: "superclass");
152: private final String name;
153:
154: public Declarer(String name) {
155: this .name = name;
156: }
157:
158: public String toString() {
159: return name;
160: }
161: }
162: }
|