Objectivity for Java Reference

com.objy.db.app
Class ToManyRelationship

java.lang.Object
  |
  +--com.objy.db.app.ToManyRelationship
All Implemented Interfaces:
Serializable

public final class ToManyRelationship
extends Object
implements Serializable

Represents a to-many relationship on a class.

About To-Many Relationships

The class on which a to-many relationship is being defined must declare a non-static relationship field of type ToManyRelationship. Objectivity for Java initializes this field with an object that will support the relationship services at runtime.

Defining a relationship makes it possible to relate objects. You use the methods defined on this class to actually create and access relationships between objects.

For additional information, see Relationships.

Related Classes

The ToOneRelationship class represents a to-one relationship.

API Summary

Functionality
Adding and Deleting Relationships add(Object)
remove(Object)
clear()
Testing includes(Object)
exists()
Finding Related Objects scan()
scan(String)

See Also:
Serialized Form

Method Summary
 void add(Object object)
          Adds a relationship between this object and the specified object.
 void clear()
          Removes all relationships with this object.
 boolean exists()
          Tests whether any objects are related to this object.
 boolean includes(Object object)
          Tests whether this object is related to the specified object.
 void remove(Object object)
          Removes a relationship between this object and the specified object.
 Iterator scan()
          Initializes an iterator to find all objects related to this object.
 Iterator scan(String predicate)
          Initializes an iterator to find all objects related to this object that satisfy the specified predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public void add(Object object)
Adds a relationship between this object and the specified object.

Parameters:
object - The object being added to the relationship. If object is transient, this method makes it persistent. If object is null, this method is equivalent to clear.

remove

public void remove(Object object)
Removes a relationship between this object and the specified object.

This method throws an ObjyRuntimeException if the specified object is not related by this relationship.

Parameters:
object - The object with which the relationship exists.

clear

public void clear()
Removes all relationships with this object.

includes

public boolean includes(Object object)
Tests whether this object is related to the specified object.

Parameters:
object - The object whose relationship is being tested.

Returns:
True if this object is related to the specified object; otherwise, false.

exists

public boolean exists()
Tests whether any objects are related to this object.

Returns:
True if any objects are related to this object; otherwise, false.

scan

public Iterator scan()
Initializes an iterator to find all objects related to this object.

Returns:
An iterator that finds the specified objects.

scan

public Iterator scan(String predicate)
Initializes an iterator to find all objects related to this object that satisfy the specified predicate.

If predicate-scan autoflush is enabled for the connection object, this method will flush any modified objects to the federated database before performing the scan. Otherwise, the result of the scan may contain out-of-date information.

Parameters:
predicate - The condition that each retrieved object must satisfy, expressed in the Objectivity/DB predicate query language.

Returns:
An iterator that finds the specified objects.

See Also:
Connection.setPredicateScanAutoFlush(boolean), Connection.isPredicateScanAutoFlush()

Objectivity for Java Reference

Copyright © 2000 Objectivity, Inc. All rights reserved.