org.apache.jdo.model.jdo
Interface JDORelationship

All Superinterfaces:
JDOElement
All Known Subinterfaces:
JDOArray, JDOCollection, JDOMap, JDOReference
All Known Implementing Classes:
JDOArrayImplCaching, JDOArrayImplDynamic, JDOCollectionImplCaching, JDOCollectionImplDynamic, JDOMapImplCaching, JDOMapImplDynamic, JDOReferenceImplCaching, JDOReferenceImplDynamic, JDORelationshipImpl

public interface JDORelationship
extends JDOElement

JDORelationship is the super interface for all interfaces representing JDO relationship metadata of a managed field of a persistence-capable class.

Author:
Michael Bouschen

Field Summary
static int CARDINALITY_N
          Constant representing the cardinality n used for lower and upper bounds.
static int CARDINALITY_ONE
          Constant representing the cardinality one used for lower and upper bounds.
static int CARDINALITY_ZERO
          Constant representing the cardinality zero used for lower and upper bounds.
 
Method Summary
 JDOField getDeclaringField()
          Get the declaring field of this JDORelationship.
 JDORelationship getInverseRelationship()
          Get the inverse JDORelationship in the case of a two-way relationship.
 java.lang.String getInverseRelationshipName()
          Get the relative name of the inverse relationship field for this relationship.
 int getLowerBound()
          Get the lower cardinality bound for this relationship element.
 JDORelationship getMappedBy()
          Get the mappedBy relationship.
 JDOClass getRelatedJDOClass()
          Get the JDOClass corresponding to the type or element of this relationship.
 int getUpperBound()
          Get the upper cardinality bound for this relationship element.
 boolean isJDOArray()
          Determines whether this JDORelationship represents an array relationship or not.
 boolean isJDOCollection()
          Determines whether this JDORelationship represents a collection relationship or not.
 boolean isJDOMap()
          Determines whether this JDORelationship represents a map relationship or not.
 boolean isJDOReference()
          Determines whether this JDORelationship represents a reference relationship or not.
 boolean isOwner()
          Determines whether this side of a two-way relationship is the owning side.
 void setDeclaringField(JDOField declaringField)
          Set the declaring field of this JDORelationship.
 void setInverseRelationship(JDORelationship inverseRelationship)
          Deprecated. - call setMappedBy instead
 void setLowerBound(int lowerBound)
          Set the lower cardinality bound for this relationship element.
 void setMappedBy(JDORelationship mappedBy)
          Set the mappedBy relationship for this relationship.
 void setUpperBound(int upperBound)
          Set the upper cardinality bound for this relationship element.
 
Methods inherited from interface org.apache.jdo.model.jdo.JDOElement
addPropertyChangeListener, addVetoableChangeListener, createJDOExtension, getJDOExtensions, removeJDOExtension, removePropertyChangeListener, removeVetoableChangeListener
 

Field Detail

CARDINALITY_ZERO

static final int CARDINALITY_ZERO
Constant representing the cardinality zero used for lower and upper bounds.

See Also:
Constant Field Values

CARDINALITY_ONE

static final int CARDINALITY_ONE
Constant representing the cardinality one used for lower and upper bounds.

See Also:
Constant Field Values

CARDINALITY_N

static final int CARDINALITY_N
Constant representing the cardinality n used for lower and upper bounds.

See Also:
Constant Field Values
Method Detail

getLowerBound

int getLowerBound()
Get the lower cardinality bound for this relationship element.

Returns:
the lower cardinality bound

setLowerBound

void setLowerBound(int lowerBound)
                   throws ModelException
Set the lower cardinality bound for this relationship element.

Parameters:
lowerBound - an integer indicating the lower cardinality bound
Throws:
ModelException - if impossible

getUpperBound

int getUpperBound()
Get the upper cardinality bound for this relationship element.

Returns:
the upper cardinality bound

setUpperBound

void setUpperBound(int upperBound)
                   throws ModelException
Set the upper cardinality bound for this relationship element.

Parameters:
upperBound - an integer indicating the upper cardinality bound
Throws:
ModelException - if impossible

getDeclaringField

JDOField getDeclaringField()
Get the declaring field of this JDORelationship.

Returns:
the field that owns this JDORelationship, or null if the element is not attached to any field

setDeclaringField

void setDeclaringField(JDOField declaringField)
                       throws ModelException
Set the declaring field of this JDORelationship.

Parameters:
declaringField - the declaring field of this relationship element
Throws:
ModelException - if impossible

getRelatedJDOClass

JDOClass getRelatedJDOClass()
Get the JDOClass corresponding to the type or element of this relationship.

Returns:
the related class

getMappedBy

JDORelationship getMappedBy()
Get the mappedBy relationship. If there is no mappedBy relationship set, the method checks the mappedBy name as specified in the declaring field and resolves the relationship. The method return null if there is no mappedBy relationship set and there is no mappedBy name specified on the declaring field.

Returns:
the mappedBy relationship if available; null otherwise.

setMappedBy

void setMappedBy(JDORelationship mappedBy)
                 throws ModelException
Set the mappedBy relationship for this relationship. This method automatically updates the mappedBy name of the declaring field of this relationship.

Parameters:
mappedBy - the mappedBy relationship.
Throws:
ModelException - if impossible

getInverseRelationshipName

java.lang.String getInverseRelationshipName()
Get the relative name of the inverse relationship field for this relationship. In the case of two-way relationships, the two relationships involved are inverses of each other. If this relationship element does not participate in a two-way relationship, this returns null. Note that it is possible to have this method return a value, but because of the combination of related class and lookup, there may be no corresponding JDORelationship which can be found.

Returns:
the relative name of the inverse JDORelationship
See Also:
getInverseRelationship()

getInverseRelationship

JDORelationship getInverseRelationship()
Get the inverse JDORelationship in the case of a two-way relationship.

Returns:
the inverse relationship

setInverseRelationship

void setInverseRelationship(JDORelationship inverseRelationship)
                            throws ModelException
Deprecated. - call setMappedBy instead

Set the inverse JDORelationship in the case of a two-way relationship. The two relationship elements involved are set as inverses of each other and the old inverse is unset.

Parameters:
inverseRelationship - the inverse relationship
Throws:
ModelException - if impossible

isOwner

boolean isOwner()
Determines whether this side of a two-way relationship is the owning side.

Returns:
true if this side is the owning side; false otherwise.

isJDOReference

boolean isJDOReference()
Determines whether this JDORelationship represents a reference relationship or not. A return of true means this JDORelationship is a JDOReference instance.

Returns:
true if this JDORelationship represents a reference relationship; false otherwise.

isJDOCollection

boolean isJDOCollection()
Determines whether this JDORelationship represents a collection relationship or not. A return of true means this JDORelationship is a JDOCollection instance.

Returns:
true if this JDORelationship represents a collection relationship; false otherwise.

isJDOArray

boolean isJDOArray()
Determines whether this JDORelationship represents an array relationship or not. A return of true means this JDORelationship is a JDOArray instance.

Returns:
true if this JDORelationship represents an array relationship; false otherwise.

isJDOMap

boolean isJDOMap()
Determines whether this JDORelationship represents a map relationship or not. A return of true means this JDORelationship is a JDOMap instance.

Returns:
true if this JDORelationship represents a map relationship; false otherwise.


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.