|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.scooterframework.orm.activerecord.AssociatedRecords
com.scooterframework.orm.activerecord.AssociatedRecordsHMT
public class AssociatedRecordsHMT
AssociatedRecordsHMT class contains a list of ActiveRecord objects and its owner in a has-many-through association.
| Field Summary |
|---|
| Fields inherited from class com.scooterframework.orm.activerecord.AssociatedRecords |
|---|
associatedRecords, latestRecordsLoaded, log, recordRelation |
| Constructor Summary | |
|---|---|
AssociatedRecordsHMT(RecordRelation recordRelation)
|
|
AssociatedRecordsHMT(RecordRelation recordRelation,
java.util.List<? extends ActiveRecord> records)
|
|
| Method Summary | |
|---|---|
AssociatedRecords |
add(ActiveRecord record,
java.util.Map<java.lang.String,java.lang.Object> joinInput)
Adds a record to the association. |
AssociatedRecords |
add(java.util.List<? extends ActiveRecord> records)
Adds a list of records to the association. |
AssociatedRecords |
add(java.util.List<? extends ActiveRecord> records,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> joinInputs)
Adds a list of records to the association. |
protected int |
countRecordsInDB()
Count number of associated records in the database. |
AssociatedRecords |
delete(java.util.List<? extends ActiveRecord> records)
Deletes a list objects from the associated list and delete the records in database whether the objects are dependent on the owner or not. |
AssociatedRecords |
detach(ActiveRecord target,
boolean keepJoinRecord)
Removes target record from the association. |
AssociatedRecords |
detach(java.util.List<? extends ActiveRecord> records)
Removes a list of records from the association. |
AssociatedRecords |
detach(java.util.List<? extends ActiveRecord> records,
boolean keepJoinRecord)
Removes a list of records from the association. |
ActiveRecord |
getJoinRecord(ActiveRecord target)
Retrieves the join record between the owner and the target. |
AssociatedRecords |
replace(java.util.List<? extends ActiveRecord> records)
This feature is not supported for has-many-through relation. |
| Methods inherited from class com.scooterframework.orm.activerecord.AssociatedRecords |
|---|
add, cleanCache, clear, count, delete, detach, findBy, getOwner, getRecord, getRecords, getRecords, getRelation, getSqlService, hasLoadedFromDatabase, isEmpty, ownerIsNew, removeRecordFromList, size, storeLoadedAssociatedRecords, validateRecordType |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AssociatedRecordsHMT(RecordRelation recordRelation)
public AssociatedRecordsHMT(RecordRelation recordRelation,
java.util.List<? extends ActiveRecord> records)
| Method Detail |
|---|
public AssociatedRecords add(ActiveRecord record,
java.util.Map<java.lang.String,java.lang.Object> joinInput)
record - A record to be added to the relation.joinInput - A map of input data for the join record.
public AssociatedRecords add(java.util.List<? extends ActiveRecord> records)
add in class AssociatedRecordsrecords - a list of records to be added to the relation.
public AssociatedRecords add(java.util.List<? extends ActiveRecord> records,
java.util.List<java.util.Map<java.lang.String,java.lang.Object>> joinInputs)
records - a list of records to be added to the relation.joinInputs - a list of input data map for the through table.
public AssociatedRecords detach(ActiveRecord target,
boolean keepJoinRecord)
Removes target record from the association. The record is not deleted. The join record is deleted if the value of the keepJoinRecord input is false or the join record depends on the record to be deleted.
If the owner object doesn't exist in database, only those objects that have been added to the relation before can be detached.
target - a record to be detached from the association.keepJoinRecord - if true, keep the join record. Otherwise, delete it.
public AssociatedRecords detach(java.util.List<? extends ActiveRecord> records)
Removes a list of records from the association. No record is deleted. Only the join record is deleted.
If the owner object doesn't exist in database, only those objects that have been added to the relation before can be detached.
detach in class AssociatedRecordsrecords - list of records to be detached.
public AssociatedRecords detach(java.util.List<? extends ActiveRecord> records,
boolean keepJoinRecord)
Removes a list of records from the association. No record is deleted. The join record is deleted if the value of the keepJoinRecord input is false or the join record depends on the record to be deleted.
Proper use of keepJoinRecord parameter is good for a three-way join association.
If the owner object doesn't exist in database, only those objects that have been added to the relation before can be detached.
records - list of records to be detached.keepJoinRecord - if true, keep the join record. Otherwise, delete it.
public AssociatedRecords delete(java.util.List<? extends ActiveRecord> records)
Deletes a list objects from the associated list and delete the records in database whether the objects are dependent on the owner or not.
The associated records in the join table can either be deleted or have its foreign key nullified, depending on how you specify the cascade property in the "to-be-deleted" record class.
If the owner object doesn't exist in database, only those objects that have been added to the relation before can be detached.
delete in class AssociatedRecordsrecords - a list of records to be deleted.
public AssociatedRecords replace(java.util.List<? extends ActiveRecord> records)
This feature is not supported for has-many-through relation.
This is equivalent to detach() and add(records).
Removes all existing associated objects from the associated list by setting their foreign keys to NULL. The records are not deleted unless they depend on the owner.
Adds the new records to the association.
replace in class AssociatedRecordspublic ActiveRecord getJoinRecord(ActiveRecord target)
target - the associated record
protected int countRecordsInDB()
countRecordsInDB in class AssociatedRecords
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||