org.apache.ojb.broker.metadata
Class ObjectReferenceDescriptor

java.lang.Object
  extended by org.apache.ojb.broker.metadata.AttributeDescriptorBase
      extended by org.apache.ojb.broker.metadata.ObjectReferenceDescriptor
All Implemented Interfaces:
java.io.Serializable, AttributeContainer, RepositoryElements, XmlCapable
Direct Known Subclasses:
CollectionDescriptor, SuperReferenceDescriptor

public class ObjectReferenceDescriptor
extends AttributeDescriptorBase
implements XmlCapable

Describes a Field containing a reference to another class. Provides handling for foreign keys etc.
Note: Be careful when use references of this class or caching instances of this class, because instances could become invalid (see MetadataManager).

Author:
Thomas Mahler
See Also:
Serialized Form

Field Summary
static int CASCADE_LINK
           
static int CASCADE_NONE
           
static int CASCADE_OBJECT
           
 
Fields inherited from interface org.apache.ojb.broker.metadata.RepositoryElements
_NEXT, ACCEPT_LOCKS, ACCESS, ATTRIBUTE, ATTRIBUTE_NAME, ATTRIBUTE_VALUE, AUTO_DELETE, AUTO_INCREMENT, AUTO_RETRIEVE, AUTO_UPDATE, BATCH_MODE, CASCADE_LINK_STR, CASCADE_NONE_STR, CASCADE_OBJECT_STR, CLASS_DESCRIPTOR, CLASS_EXTENT, CLASS_NAME, CLASS_PROXY, CLASS_REF, COLLECTION_CLASS, COLLECTION_DESCRIPTOR, COLUMN_NAME, CON_LOG_ABANDONED, CON_MAX_ACTIVE, CON_MAX_IDLE, CON_MAX_WAIT, CON_MIN_EVICTABLE_IDLE_TIME_MILLIS, CON_NUM_TESTS_PER_EVICTION_RUN, CON_REMOVE_ABANDONED, CON_REMOVE_ABANDONED_TIMEOUT, CON_TEST_ON_BORROW, CON_TEST_ON_RETURN, CON_TEST_WHILE_IDLE, CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS, CON_WHEN_EXHAUSTED_ACTION, CONNECTION_FACTORY, CONNECTION_POOL, CONSTANT_ARGUMENT, DATASOURCE_NAME, DBMS_NAME, DEFAULT_CONNECTION, DELETE_PROCEDURE, DOCUMENTATION, DRIVER_NAME, EAGER_RELEASE, EXTENDS, FACTORY_CLASS, FACTORY_METHOD, FIELD_CONVERSION, FIELD_DESCRIPTOR, FIELD_ID_REF, FIELD_NAME, FIELD_REF, FK_POINTING_TO_ITEMS_CLASS, FK_POINTING_TO_THIS_CLASS, FOREIGN_KEY, ID, IGNORE_AUTOCOMMIT_EXCEPTION, INCLUDE_ALL_FIELDS, INCLUDE_PK_FIELDS_ONLY, INDEX_COLUMN, INDEX_DESCRIPTOR, INDEXED, INDIRECTION_TABLE, INITIALIZATION_METHOD, INSERT_PROCEDURE, INVERSE_FK, ISOLATION_LEVEL, ITEMS_CLASS, JCD_ALIAS, JDBC_CONNECTION_DESCRIPTOR, JDBC_LEVEL, JDBC_TYPE, LENGTH, LOCKING, MAPPING_REPOSITORY, NAME, NULLABLE, OBJECT_CACHE, ORDERBY, OTM_DEPENDENT, PRECISION, PRIMARY_KEY, PROXY_PREFETCHING_LIMIT, PROXY_REFERENCE, QUERY_CUSTOMIZER, REFERENCE_DESCRIPTOR, REFERENCED_CLASS, REFRESH, REPOSITORY_VERSION, RETURN, RETURN_FIELD_REF, ROW_READER, RUNTIME_ARGUMENT, SCALE, SCHEMA_NAME, SEQUENCE_MANAGER, SEQUENCE_MANAGER_CLASS, SEQUENCE_NAME, SORT, TABLE_NAME, TAG_ACCESS, TAG_ACCESS_ANONYMOUS, TAG_ACCESS_READONLY, TAG_ACCESS_READWRITE, TAG_SUPER, UNIQUE, UPDATE_LOCK, UPDATE_PROCEDURE, URL_DBALIAS, URL_PROTOCOL, URL_SUBPROTOCOL, USE_AUTOCOMMIT, USER_NAME, USER_PASSWD, VALIDATION_QUERY, VALUE
 
Constructor Summary
ObjectReferenceDescriptor(ClassDescriptor descriptor)
           
 
Method Summary
 void addAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          Store the specified attribute and it's value.
 void addForeignKeyField(int newId)
          add a foreign key field ID
 void addForeignKeyField(java.lang.String newField)
          add a foreign key field
 java.lang.String getAttribute(java.lang.String attributeName)
          Get the value of an attribute
 java.lang.String getAttribute(java.lang.String attributeName, java.lang.String defaultValue)
          Get the value of an attribute
 java.lang.String[] getAttributeNames()
          Returns an array of the names of all atributes of this descriptor.
 java.util.Map getAttributes()
          Returns the attribute map (name, value) of this descriptor.
 java.lang.String getCascadeAsString(int cascade)
           
 boolean getCascadeDelete()
          Deprecated. use getCascadingDelete() instead.
 boolean getCascadeRetrieve()
           
 boolean getCascadeStore()
          Deprecated. use getCascadingStore() instead.
 int getCascadingDelete()
           
 int getCascadingStore()
           
 FieldDescriptor[] getForeignKeyFieldDescriptors(ClassDescriptor cld)
           
 java.util.Vector getForeignKeyFields()
           
 java.lang.Object[] getForeignKeyValues(java.lang.Object obj, ClassDescriptor mif)
          Returns an Object array of all FK field values of the specified object.
 java.lang.Class getItemClass()
           
 java.lang.String getItemClassName()
           
 java.lang.Class getItemProxyClass()
           
 boolean getOtmDependent()
           
 int getProxyPrefetchingLimit()
           
 boolean hasConstraint()
          Returns true if a foreign key constraint to the referenced object is declared, else false is returned.
 boolean isLazy()
          Gets the lazy.
 boolean isRefresh()
          Gets the refresh.
 boolean isSuperReferenceDescriptor()
          Returns true if this descriptor was used to describe a reference to a super class of an object.
 void setCascadeDelete(boolean cascade)
          Deprecated. use setCascadingDelete(int)
 void setCascadeRetrieve(boolean b)
           
 void setCascadeStore(boolean cascade)
          Deprecated. use setCascadingStore(int) instead.
 void setCascadingDelete(int cascade)
           
 void setCascadingDelete(java.lang.String value)
           
 void setCascadingStore(int cascade)
           
 void setCascadingStore(java.lang.String value)
           
 void setConstraint(boolean constraint)
          Set a foreign key constraint flag for this reference - see hasConstraint()
 void setForeignKeyFields(java.util.Vector vec)
           
 void setItemClass(java.lang.Class c)
          sets the item class
 void setLazy(boolean lazy)
          Sets the lazy.
 void setOtmDependent(boolean b)
           
 void setProxyPrefetchingLimit(int proxyPrefetchingLimit)
           
 void setRefresh(boolean refresh)
          Sets the refresh.
 java.lang.String toString()
           
 java.lang.String toXML()
          returns the XML marshalled version of this instance.
 
Methods inherited from class org.apache.ojb.broker.metadata.AttributeDescriptorBase
getAttributeName, getClassDescriptor, getPersistentField, setClassDescriptor, setPersistentField, setPersistentField
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CASCADE_NONE

public static final int CASCADE_NONE
See Also:
Constant Field Values

CASCADE_LINK

public static final int CASCADE_LINK
See Also:
Constant Field Values

CASCADE_OBJECT

public static final int CASCADE_OBJECT
See Also:
Constant Field Values
Constructor Detail

ObjectReferenceDescriptor

public ObjectReferenceDescriptor(ClassDescriptor descriptor)
Method Detail

getItemProxyClass

public java.lang.Class getItemProxyClass()
                                  throws PersistenceBrokerException
Throws:
PersistenceBrokerException

getForeignKeyFieldDescriptors

public FieldDescriptor[] getForeignKeyFieldDescriptors(ClassDescriptor cld)

getForeignKeyValues

public java.lang.Object[] getForeignKeyValues(java.lang.Object obj,
                                              ClassDescriptor mif)
                                       throws PersistenceBrokerException
Returns an Object array of all FK field values of the specified object. If the specified object is an unmaterialized Proxy, it will be materialized to read the FK values.

Throws:
MetadataException - if an error occours while accessing ForeingKey values on obj
PersistenceBrokerException

getItemClass

public java.lang.Class getItemClass()

getItemClassName

public java.lang.String getItemClassName()
Returns:
the fully qualified name of the item class for this descriptor.

setItemClass

public void setItemClass(java.lang.Class c)
sets the item class

Parameters:
c - the items class object

getForeignKeyFields

public java.util.Vector getForeignKeyFields()

setForeignKeyFields

public void setForeignKeyFields(java.util.Vector vec)

addForeignKeyField

public void addForeignKeyField(int newId)
add a foreign key field ID


addForeignKeyField

public void addForeignKeyField(java.lang.String newField)
add a foreign key field


isRefresh

public boolean isRefresh()
Gets the refresh.

Returns:
Returns a boolean

setRefresh

public void setRefresh(boolean refresh)
Sets the refresh.

Parameters:
refresh - The refresh to set

isLazy

public boolean isLazy()
Gets the lazy.

Returns:
Returns a boolean

setLazy

public void setLazy(boolean lazy)
Sets the lazy.

Parameters:
lazy - The lazy to set

getCascadeRetrieve

public boolean getCascadeRetrieve()

setCascadeRetrieve

public void setCascadeRetrieve(boolean b)

getCascadingStore

public int getCascadingStore()

setCascadingStore

public void setCascadingStore(int cascade)

setCascadingStore

public void setCascadingStore(java.lang.String value)

getCascadeStore

public boolean getCascadeStore()
Deprecated. use getCascadingStore() instead.


setCascadeStore

public void setCascadeStore(boolean cascade)
Deprecated. use setCascadingStore(int) instead.


getCascadingDelete

public int getCascadingDelete()

setCascadingDelete

public void setCascadingDelete(int cascade)

setCascadingDelete

public void setCascadingDelete(java.lang.String value)

getCascadeDelete

public boolean getCascadeDelete()
Deprecated. use getCascadingDelete() instead.


setCascadeDelete

public void setCascadeDelete(boolean cascade)
Deprecated. use setCascadingDelete(int)


getCascadeAsString

public java.lang.String getCascadeAsString(int cascade)

getProxyPrefetchingLimit

public int getProxyPrefetchingLimit()

setProxyPrefetchingLimit

public void setProxyPrefetchingLimit(int proxyPrefetchingLimit)

getOtmDependent

public boolean getOtmDependent()

setOtmDependent

public void setOtmDependent(boolean b)

isSuperReferenceDescriptor

public boolean isSuperReferenceDescriptor()
Returns true if this descriptor was used to describe a reference to a super class of an object.

Returns:
always false for this instance.

hasConstraint

public boolean hasConstraint()
Returns true if a foreign key constraint to the referenced object is declared, else false is returned.


setConstraint

public void setConstraint(boolean constraint)
Set a foreign key constraint flag for this reference - see hasConstraint()

Parameters:
constraint - If set true, signals a foreign key constraint in database.

toString

public java.lang.String toString()
Overrides:
toString in class AttributeDescriptorBase

toXML

public java.lang.String toXML()
Description copied from interface: XmlCapable
returns the XML marshalled version of this instance.

Specified by:
toXML in interface XmlCapable
Returns:
the XML String representing this object.

addAttribute

public void addAttribute(java.lang.String attributeName,
                         java.lang.String attributeValue)
Description copied from interface: AttributeContainer
Store the specified attribute and it's value.

Specified by:
addAttribute in interface AttributeContainer
Parameters:
attributeName - the name of the attribute to retrieve
attributeValue - the attribute's value
See Also:
AttributeContainer.addAttribute(String, String)

getAttribute

public java.lang.String getAttribute(java.lang.String attributeName,
                                     java.lang.String defaultValue)
Description copied from interface: AttributeContainer
Get the value of an attribute

Specified by:
getAttribute in interface AttributeContainer
Parameters:
attributeName - the attribute to retrieve
defaultValue - the value to return if the attribute is not present
Returns:
the attribute value
See Also:
AttributeContainer.getAttribute(String, String)

getAttribute

public java.lang.String getAttribute(java.lang.String attributeName)
Description copied from interface: AttributeContainer
Get the value of an attribute

Specified by:
getAttribute in interface AttributeContainer
Parameters:
attributeName - the attribute to retrieve
Returns:
the attribute value
See Also:
AttributeContainer.getAttribute(String)

getAttributes

public java.util.Map getAttributes()
Returns the attribute map (name, value) of this descriptor. Note that the returned map is not modifiable.

Returns:
The attributes

getAttributeNames

public java.lang.String[] getAttributeNames()
Returns an array of the names of all atributes of this descriptor.

Returns:
The list of attribute names (will not be null)


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30