com.solarmetric.kodo.impl.jdbc.ormapping
Class ManyToManyMapping
java.lang.Object
|
+--com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
|
+--com.solarmetric.kodo.impl.jdbc.ormapping.FieldMapping
|
+--com.solarmetric.kodo.impl.jdbc.ormapping.AbstractCollectionMapping
|
+--com.solarmetric.kodo.impl.jdbc.ormapping.ManyToManyMapping
- All Implemented Interfaces:
- LoadSecondary, Relation, SecondaryTable, StoreSecondary
- Direct Known Subclasses:
- OrderedManyToManyMapping
- public class ManyToManyMapping
- extends AbstractCollectionMapping
- implements Relation, LoadSecondary, StoreSecondary, SecondaryTable
Represents a M-M mapping with a persistent object type.
M-M mappings are stored in a separate table from the primary values
of the owning class. Each row of the table holds two values: a single
PK value of the related object collection in the data column, and the PK
value of the owning object in the ref column.
|
Method Summary |
protected void |
addValueMatchCondition(SQLStatement sql,
Object value,
ClassResolver resolver)
|
protected boolean |
canMap(FieldMetaData fmd,
ClassResolver resolver)
|
void |
delete(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
Delete the field from the secondary table for this mapping. |
Column[] |
getRelationPKColumns()
Return the primary key column(s) of the related object. |
Class |
getRelationType()
Return the type the mapping relates to. |
Table |
getSecondaryTable()
Return the secondary table used by this mapping. |
protected void |
insert(Insert insert,
Object value,
int index,
StateManagerImpl sm,
Object[] pks,
int field)
|
void |
insert(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
Insert the given field into the secondary table for this mapping. |
protected void |
install(FieldMetaData fmd,
JDBCConfiguration conf,
ClassResolver resolver,
DBDictionary dict)
|
boolean |
isReadOnly()
Return true if this mapping has been set read only, and
will not insert, update, or delete values. |
protected static boolean |
isReadOnly(FieldMetaData fmd,
FieldMetaData imd)
|
void |
join(ObjectSelect sel)
Join this mapping to the given select statement. |
void |
load(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
Load the value of this mapping for the given instance. |
protected void |
select(ObjectSelect sel,
StateManagerImpl sm,
Object[] pks,
int field)
|
void |
setReadOnly(boolean ro)
Set this mapping to be read-only. |
void |
setRelationPKColumns(Column[] val)
|
void |
update(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
Update the given field into the secondary table for this mapping. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ManyToManyMapping
public ManyToManyMapping()
getRelationType
public Class getRelationType()
- Description copied from interface:
Relation
- Return the type the mapping relates to.
- Specified by:
getRelationType in interface Relation
getRelationPKColumns
public Column[] getRelationPKColumns()
- Description copied from interface:
Relation
- Return the primary key column(s) of the related object.
- Specified by:
getRelationPKColumns in interface Relation
setRelationPKColumns
public void setRelationPKColumns(Column[] val)
isReadOnly
public boolean isReadOnly()
- Return true if this mapping has been set read only, and
will not insert, update, or delete values.
setReadOnly
public void setReadOnly(boolean ro)
- Set this mapping to be read-only. When two classes
share a many-to-many table between them, one of the classes must
mark their mapping read only to prevent duplicate inserts.
join
public void join(ObjectSelect sel)
- Description copied from class:
FieldMapping
- Join this mapping to the given select statement. For basic mappings,
this no-op method implementation will suffice. Secondary table
mappings should override this method to do the proper join.
- Overrides:
join in class FieldMapping
insert
public void insert(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
throws SQLException
- Description copied from interface:
StoreSecondary
- Insert the given field into the secondary table for this mapping.
- Specified by:
insert in interface StoreSecondary- Overrides:
insert in class AbstractCollectionMapping
update
public void update(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
throws SQLException
- Description copied from interface:
StoreSecondary
- Update the given field into the secondary table for this mapping.
- Specified by:
update in interface StoreSecondary- Overrides:
update in class AbstractCollectionMapping
delete
public void delete(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
throws SQLException
- Description copied from interface:
StoreSecondary
- Delete the field from the secondary table for this mapping.
- Specified by:
delete in interface StoreSecondary- Overrides:
delete in class AbstractCollectionMapping
load
public void load(StateManagerImpl sm,
Object[] pks,
int field,
SQLExecutionManager sqlem)
throws SQLException
- Description copied from interface:
LoadSecondary
- Load the value of this mapping for the given instance.
Relations to other persistent types are loaded
as PersistenceCapable instances.
- Specified by:
load in interface LoadSecondary
- Following copied from interface:
com.solarmetric.kodo.impl.jdbc.ormapping.LoadSecondary
- Parameters:
stmnt - The caller is responsible for closing the statement.
select
protected void select(ObjectSelect sel,
StateManagerImpl sm,
Object[] pks,
int field)
insert
protected void insert(Insert insert,
Object value,
int index,
StateManagerImpl sm,
Object[] pks,
int field)
addValueMatchCondition
protected void addValueMatchCondition(SQLStatement sql,
Object value,
ClassResolver resolver)
canMap
protected boolean canMap(FieldMetaData fmd,
ClassResolver resolver)
install
protected void install(FieldMetaData fmd,
JDBCConfiguration conf,
ClassResolver resolver,
DBDictionary dict)
isReadOnly
protected static boolean isReadOnly(FieldMetaData fmd,
FieldMetaData imd)
getSecondaryTable
public Table getSecondaryTable()
- Description copied from interface:
SecondaryTable
- Return the secondary table used by this mapping.
- Specified by:
getSecondaryTable in interface SecondaryTable
Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.