Class InValueDiscriminatorStrategy
- java.lang.Object
-
- org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
-
- org.apache.openjpa.jdbc.meta.strats.AbstractDiscriminatorStrategy
-
- org.apache.openjpa.jdbc.meta.strats.InValueDiscriminatorStrategy
-
- All Implemented Interfaces:
java.io.Serializable,DiscriminatorStrategy,Strategy
- Direct Known Subclasses:
ClassNameDiscriminatorStrategy,ValueMapDiscriminatorStrategy
public abstract class InValueDiscriminatorStrategy extends AbstractDiscriminatorStrategy
Base discriminator strategy that determines the class of database records using a column holding a value mapped to a class, and limits SELECTs using an IN (...) statement.- Author:
- Abe White
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractDiscriminatorStrategy
disc, isFinal
-
-
Constructor Summary
Constructors Constructor Description InValueDiscriminatorStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.ClassgetClass(java.lang.Object val, JDBCStore store)Convert the given discriminator value to the corresponding class.java.lang.ClassgetClass(JDBCStore store, ClassMapping base, Result res)Return the class for the current result row.SQLBuffergetClassConditions(Select sel, Joins joins, ClassMapping base, boolean subclasses)Return SQL to limit the classes selected as much as possible to the given base class, and optionally its subclasses.protected abstract java.lang.ObjectgetDiscriminatorValue(ClassMapping cls)Return the discriminator value for the given type.protected abstract intgetJavaType()Return the Java type code fromJavaTypesfor the discriminator values.booleanhasClassConditions(ClassMapping base, boolean subclasses)Whether any class conditions are necessary.voidinsert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)Set values for the mapping into the proper rows.voidmap(boolean adapt)Map the owning mapping using this strategy.booleanselect(Select sel, ClassMapping mapping)Select the data for this Discriminator.-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractDiscriminatorStrategy
loadSubclasses, setDiscriminator
-
Methods inherited from class org.apache.openjpa.jdbc.meta.strats.AbstractStrategy
customDelete, customInsert, customUpdate, delete, getAlias, initialize, isCustomDelete, isCustomInsert, isCustomUpdate, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.jdbc.meta.Strategy
customDelete, customInsert, customUpdate, delete, getAlias, initialize, isCustomDelete, isCustomInsert, isCustomUpdate, update
-
-
-
-
Method Detail
-
getJavaType
protected abstract int getJavaType()
Return the Java type code fromJavaTypesfor the discriminator values. This method is only used during mapping installation.
-
getDiscriminatorValue
protected abstract java.lang.Object getDiscriminatorValue(ClassMapping cls)
Return the discriminator value for the given type.
-
getClass
protected abstract java.lang.Class getClass(java.lang.Object val, JDBCStore store) throws java.lang.ClassNotFoundExceptionConvert the given discriminator value to the corresponding class.- Throws:
java.lang.ClassNotFoundException
-
map
public void map(boolean adapt)
Description copied from interface:StrategyMap the owning mapping using this strategy.- Specified by:
mapin interfaceStrategy- Overrides:
mapin classAbstractStrategy- Parameters:
adapt- if true, use the owning mapping's raw mapping info to set its ORM data; if false, ORM data will already be set
-
insert
public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm) throws java.sql.SQLException
Description copied from interface:StrategySet values for the mapping into the proper rows. For class mappings, this method will be called only after the corresponding method has been called for all fields of this mapping.- Specified by:
insertin interfaceStrategy- Overrides:
insertin classAbstractStrategy- Throws:
java.sql.SQLException
-
select
public boolean select(Select sel, ClassMapping mapping)
Description copied from interface:DiscriminatorStrategySelect the data for this Discriminator.- Specified by:
selectin interfaceDiscriminatorStrategy- Overrides:
selectin classAbstractDiscriminatorStrategymapping- the known base class being selected; this may not be the base class in the inheritance hierarchy- Returns:
- true if anything was selected; false otherwise
-
getClass
public java.lang.Class getClass(JDBCStore store, ClassMapping base, Result res) throws java.sql.SQLException, java.lang.ClassNotFoundException
Description copied from interface:DiscriminatorStrategyReturn the class for the current result row.- Specified by:
getClassin interfaceDiscriminatorStrategy- Overrides:
getClassin classAbstractDiscriminatorStrategy- Throws:
java.sql.SQLExceptionjava.lang.ClassNotFoundException
-
hasClassConditions
public boolean hasClassConditions(ClassMapping base, boolean subclasses)
Description copied from interface:DiscriminatorStrategyWhether any class conditions are necessary.- Specified by:
hasClassConditionsin interfaceDiscriminatorStrategy- Overrides:
hasClassConditionsin classAbstractDiscriminatorStrategy- See Also:
DiscriminatorStrategy.getClassConditions(org.apache.openjpa.jdbc.sql.Select, org.apache.openjpa.jdbc.sql.Joins, org.apache.openjpa.jdbc.meta.ClassMapping, boolean)
-
getClassConditions
public SQLBuffer getClassConditions(Select sel, Joins joins, ClassMapping base, boolean subclasses)
Description copied from interface:DiscriminatorStrategyReturn SQL to limit the classes selected as much as possible to the given base class, and optionally its subclasses. The select and joins instances are supplied in order to get column aliases.- Specified by:
getClassConditionsin interfaceDiscriminatorStrategy- Overrides:
getClassConditionsin classAbstractDiscriminatorStrategy
-
-