|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IKey
This interface represents a mapping of a primary or foreing key in a database, to a
list of getter and setter mappings. This key mapping is a replacement for the
previous primary key mappings in the IObjectMapping interface. The previous
primary key mapping constructs did not support compound keys (multi-column keys).
The IKey
supports that. In addition a IKey
can be used to map foreign keys too.
A key mapping consists of a table name and collections of getter and setter methods
that are mapped to the columns included in the key. For a primary key the table name
is the same table
as the key exists in. For a foreign key the table name is the table the primary key the
foreign key points to exists in.
Method Summary | |
---|---|
void |
addColumn(java.lang.String column)
Adds a column to this key mapping. |
java.lang.String |
getColumn()
If this key only consists of one column, this method will return that column. |
java.util.Collection |
getColumns()
Returns the collection of columns used in this key mapping. |
java.lang.String |
getTable()
Returns the table this key mapping points to. |
boolean |
isValid(IKeyValue keyValue)
Validates an IKeyValue instance against this key. |
void |
removeColumn(java.lang.String column)
Removes a column from this key mapping |
void |
setColumns(java.util.Collection columns)
Sets the collection of columns to use in this key mapping. |
void |
setTable(java.lang.String table)
Sets the table this key points to. |
int |
size()
Returns the number of columns in this key. |
IKeyValue |
toKeyValue(java.lang.Object keyValueObject)
Wraps the given key value object in a IKeyValue instance. |
Method Detail |
---|
java.lang.String getTable()
void setTable(java.lang.String table)
table
- The table this key mapping is to point to.void addColumn(java.lang.String column)
column
- The column to add to this key mapping.void removeColumn(java.lang.String column)
column
- The column to removejava.util.Collection getColumns()
void setColumns(java.util.Collection columns)
columns
- The collection of columns to use in this key mapping.int size()
boolean isValid(IKeyValue keyValue)
IKeyValue
instance against this key.
If the key value contains values for all columns in this key,
this method returns true. False if not.
keyValue
- The key value to validate.
java.lang.String getColumn() throws PersistenceException
PersistenceException
- If this key contains zero, or more than one
column.IKeyValue toKeyValue(java.lang.Object keyValueObject) throws PersistenceException
IKeyValue
instance.
If the object to be wrapped is already a IKeyValue
instance
it will be returned unchanged.
This will only work if this IKey
instance only consists of
a single column.
keyValueObject
- The object to wrap in a IKeyValue
instance.
IKeyValue
instance wrapping the given object.
PersistenceException
- if this IKey
instance is a
compound key (multi column key), or if empty.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |