com.scooterframework.orm.activerecord
Class BelongsToRecordRelation

java.lang.Object
  extended by com.scooterframework.orm.activerecord.RecordRelation
      extended by com.scooterframework.orm.activerecord.BelongsToRecordRelation

public class BelongsToRecordRelation
extends RecordRelation

BelongsToRecordRelation class represents a has-one relation instance. For example, A belongs to B. In belongs-to relation, foreign key is hold by class A. Class A is the owner of the relation.


Field Summary
 
Fields inherited from class com.scooterframework.orm.activerecord.RecordRelation
associationDataMap, lastUsedOptions, owner, relation
 
Constructor Summary
BelongsToRecordRelation(ActiveRecord owner, BelongsToRelation relation)
           
 
Method Summary
 AssociatedRecord associatedRecord(java.lang.String options, boolean refresh)
          Find the associated record.
protected  ActiveRecord retrieveAssociatedData(java.lang.String options)
          Retrieves associated ActiveRecord data.
 
Methods inherited from class com.scooterframework.orm.activerecord.RecordRelation
allAssociatedRecords, allAssociatedRecords, allAssociatedRecords, allAssociatedRecords, associatedRecord, associatedRecord, associatedRecord, getAssociatedData, getFKDataMapForOther, getLastUsedOptions, getNullFKDataMapForOther, getOwner, getRelation, optionsChangedFromLastRetrieval, retrieveAssociatedData, retrieveAssociatedDataList, retrieveAssociatedDataList, setAssociatedData, setAssociatedData, setLastUsedOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BelongsToRecordRelation

public BelongsToRecordRelation(ActiveRecord owner,
                               BelongsToRelation relation)
Method Detail

associatedRecord

public AssociatedRecord associatedRecord(java.lang.String options,
                                         boolean refresh)
Find the associated record. For example, "invoice" belongs to "order". SQL: select * from order where order.id = ${invoice.order_id}

Overrides:
associatedRecord in class RecordRelation
Parameters:
options - A string of options.
refresh - If true, refresh data from database
Returns:
AssociatedRecord

retrieveAssociatedData

protected ActiveRecord retrieveAssociatedData(java.lang.String options)
Description copied from class: RecordRelation
Retrieves associated ActiveRecord data. This method must be implemented by the subclass of this class for either belongs-to type or has-one type.

Overrides:
retrieveAssociatedData in class RecordRelation
Parameters:
options - options used in retrieving the record
Returns:
retrieved active record instance