Class RelationshipElement

    • Field Detail

      • NONE_ACTION

        public static final int NONE_ACTION
        Constant representing no action.
        See Also:
        Constant Field Values
      • NULLIFY_ACTION

        public static final int NULLIFY_ACTION
        Constant representing nullify action.
        See Also:
        Constant Field Values
      • RESTRICT_ACTION

        public static final int RESTRICT_ACTION
        Constant representing restrict action.
        See Also:
        Constant Field Values
      • CASCADE_ACTION

        public static final int CASCADE_ACTION
        Constant representing cascade action.
        See Also:
        Constant Field Values
      • AGGREGATE_ACTION

        public static final int AGGREGATE_ACTION
        Constant representing aggregate action.
        See Also:
        Constant Field Values
    • Constructor Detail

      • RelationshipElement

        public RelationshipElement()
        Create new RelationshipElement with no implementation. This constructor should only be used for cloning and archiving.
      • RelationshipElement

        public RelationshipElement​(RelationshipElement.Impl impl,
                                   PersistenceClassElement declaringClass)
        Create new RelationshipElement with the provided implementation. The implementation is responsible for storing all properties of the object.
        Parameters:
        impl - the implementation to use
        declaringClass - the class to attach to
    • Method Detail

      • isPrefetch

        public boolean isPrefetch()
        Determines whether this relationship element should prefetch or not.
        Returns:
        true if the relationship should prefetch, false otherwise
      • setPrefetch

        public void setPrefetch​(boolean flag)
                         throws ModelException
        Set whether this relationship element should prefetch or not.
        Parameters:
        flag - - if true, the relationship is set to prefetch; otherwise, it is not
        Throws:
        ModelException - if impossible
      • getLowerBound

        public int getLowerBound()
        Get the lower cardinality bound for this relationship element.
        Returns:
        the lower cardinality bound
      • setLowerBound

        public 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

        public int getUpperBound()
        Get the upper cardinality bound for this relationship element. Returns Integer.MAX_VALUE for n
        Returns:
        the upper cardinality bound
      • setUpperBound

        public void setUpperBound​(int upperBound)
                           throws ModelException
        Set the upper cardinality bound for this relationship element.
        Parameters:
        upperBound - - an integer indicating the upper cardinality bound (use Integer.MAX_VALUE for n)
        Throws:
        ModelException - if impossible
      • getCollectionClass

        public String getCollectionClass()
        Get the collection class (for example Set, List, Vector, etc.) for this relationship element.
        Returns:
        the collection class
      • setCollectionClass

        public void setCollectionClass​(String collectionClass)
                                throws ModelException
        Set the collection class for this relationship element.
        Parameters:
        collectionClass - - a string indicating the type of collection (for example Set, List, Vector, etc.)
        Throws:
        ModelException - if impossible
      • getElementClass

        public String getElementClass()
        Get the element class for this relationship element. If primitive types are supported, you can use wrapperclass.TYPE.toString() to specify them.
        Returns:
        the element class
      • setElementClass

        public void setElementClass​(String elementClass)
                             throws ModelException
        Set the element class for this relationship element.
        Parameters:
        elementClass - - a string indicating the type of elements in the collection. If primitive types are supported, you can use wrapperclass.TYPE.toString() to specify them.
        Throws:
        ModelException - if impossible
      • getInverseRelationshipName

        public String getInverseRelationshipName()
        Get the relative name of the inverse relationship field for this relationship element. In the case of two-way relationships, the two relationship elements 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 RelationshipElement which can be found.
        Returns:
        the relative name of the inverse relationship element
        See Also:
        getInverseRelationship(com.sun.jdo.api.persistence.model.Model)
      • getInverseRelationship

        public RelationshipElement getInverseRelationship​(Model model)
        Get the inverse relationship element for this relationship element. In the case of two-way relationships, the two relationship elements 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 also possible for this method to return null even if getInverseRelationshipName() returns a value because the corresponding RelationshipElement cannot be found using the combination of related class and lookup (model).
        Parameters:
        model - the model object to be used to look it up
        Returns:
        the inverse relationship element if it exists
        See Also:
        getInverseRelationshipName()
      • setInverseRelationship

        public void setInverseRelationship​(RelationshipElement inverseRelationship,
                                           Model model)
                                    throws ModelException
        Set the inverse relationship element for this relationship element. In the case of two-way relationships, the two relationship elements involved are inverses of each other.
        Parameters:
        inverseRelationship - - a relationship element to be used as the inverse for this relationship element or null if this relationship element does not participate in a two-way relationship.
        model - the model object to be used to look up the old inverse so it can be unset
        Throws:
        ModelException - if impossible