com.scooterframework.orm.activerecord
Class HasOneRecordRelation

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

public class HasOneRecordRelation
extends RecordRelation

HasOneRecordRelation class represents a has-one relation instance. For example, A has one B. In has-one relation, foreign key is held by class B. 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
HasOneRecordRelation(ActiveRecord owner, HasOneRelation 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

HasOneRecordRelation

public HasOneRecordRelation(ActiveRecord owner,
                            HasOneRelation relation)
Method Detail

associatedRecord

public AssociatedRecord associatedRecord(java.lang.String options,
                                         boolean refresh)
Find the associated record. For example, "order" has one "invoice". SQL: select * from invoice where invoice.order_id = ${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