IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid.config
Class QueryRelationship

java.lang.Object
  extended by com.ibm.websphere.objectgrid.config.QueryRelationship
All Implemented Interfaces:
Serializable

public class QueryRelationship
extends Object
implements Serializable

A QueryRelationship represents a relationship between two BackingMap value classes. A BackingMap must have one class type defined in the value part of the map. A relationship can be established between two maps by mapping the source and target map's value classes.

The cardinality of the relationship is automatically determined by the type of the attribute field.

A relationship requires two classes, a relationship field, and optionally an inverse realtionship field.

For example: Two entities; Department and Employee, have the following bi-directional relationship:

  1. One department has many employees. the collection field in the Department class is "emps"
  2. An employee belongs to one department
 public class Department {
     private int id;
     private Collection emps;
     
     public void setEmps(Collection emps) {
         this.emps = emps;
     }
     
     public Collection getEmps() {
         return emps;
     }
     ...
 }
 
 public class Employee {
     private int id;
     private Department dept;
     
     public void setDept(Department dept) {
         this.dept = dept;
     }
     
     public Department getDept() {
         return dept;
     }
 }
 
Use the following method call to establish this bi-directional relationship.

 queryConfig.addRelationship(new QueryRelationship(
     Department.class.getName(), Employee.class.getName(), "emps", "dept"));
 

Since:
WAS XD 6.1, XC10
See Also:
Serialized Form

Constructor Summary
QueryRelationship(String sourceClass, String targetClass, String relationshipField, String invRelationshipField)
          Constructor for creating a QueryRelationship instance.
 
Method Summary
 boolean equals(Object o)
           
 String getInvRelationshipField()
          Retrieve the inverse relationship attribute name of a bi-directional relationship.
 String getRelationshipField()
          Retrieve the name of the attribute in the source class that references the key of the target class.
 String getSourceClass()
          Retrieve the name of the class representing the source of a relationship.
 String getTargetClass()
          Retrieve the name of the class representing the target of a relationship.
 int hashCode()
           
 void setInvRelationshipField(String invRelationshipField)
          Set the inverse relationship attribute name of a bi-directional relationship.
 void setRelationshipField(String relationshipField)
          Set the name of the attribute in the source class that references the key of the target class.
 void setSourceClass(String sourceClass)
          Set the name of the class representing the source of a relationship.
 void setTargetClass(String targetClass)
          Set the name of the class representing the target of a relationship.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryRelationship

public QueryRelationship(String sourceClass,
                         String targetClass,
                         String relationshipField,
                         String invRelationshipField)
Constructor for creating a QueryRelationship instance.

The sourceClass, targetClass, and relationshipField must not be null.

Parameters:
sourceClass - the source class of the relationship
targetClass - the target class of the relationship
relationshipField - the attribute in the source class that references the key of the target class.
invRelationshipField - the attribute in the target class that references the key of the source class. This value is null if a bi-directional relationship does not exist.
Method Detail

getInvRelationshipField

public String getInvRelationshipField()
Retrieve the inverse relationship attribute name of a bi-directional relationship.

Returns:
the attribute name of the inverse side of a bi-directional relationship or null if the relationship is uni-directional.

setInvRelationshipField

public void setInvRelationshipField(String invRelationshipField)
Set the inverse relationship attribute name of a bi-directional relationship.

Parameters:
invRelationshipField - the attribute name of the inverse side of a bi-directional relationship or null if the relationship is uni-directional.

getRelationshipField

public String getRelationshipField()
Retrieve the name of the attribute in the source class that references the key of the target class.

Returns:
the name of the relationship attribute.

setRelationshipField

public void setRelationshipField(String relationshipField)
Set the name of the attribute in the source class that references the key of the target class.

Parameters:
relationshipField - the name of the relationship attribute.

getSourceClass

public String getSourceClass()
Retrieve the name of the class representing the source of a relationship.

Returns:
the source class

setSourceClass

public void setSourceClass(String sourceClass)
Set the name of the class representing the source of a relationship.

Parameters:
sourceClass - the source class

getTargetClass

public String getTargetClass()
Retrieve the name of the class representing the target of a relationship.

Returns:
the target class

setTargetClass

public void setTargetClass(String targetClass)
Set the name of the class representing the target of a relationship.

Parameters:
targetClass - the target class

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Object

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.