站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

DynamicComponentType (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.type
Class DynamicComponentType

java.lang.Object
  extended bynet.sf.hibernate.type.AbstractType
      extended bynet.sf.hibernate.type.DynamicComponentType
All Implemented Interfaces:
AbstractComponentType, Serializable, Type

public class DynamicComponentType
extends AbstractType
implements AbstractComponentType

Handles "dynamic" components, represented as Maps

Author:
Gavin King
See Also:
Serialized Form

Constructor Summary
DynamicComponentType(String[] propertyNames, Type[] propertyTypes, int[] joinedFetch, Cascades.CascadeStyle[] cascade)
           
 
Method Summary
 Cascades.CascadeStyle cascade(int i)
           
 Object copy(Object original, Object target, SessionImplementor session, Object owner, Map copiedAlready)
           
 Object deepCopy(Object component)
          Return a deep copy of the persistent state, stopping at entities and at collections.
 int enableJoinedFetch(int i)
           
 boolean equals(Object object)
           
 boolean equals(Object x, Object y)
          Compare two instances of the class mapped by this type for persistence "equality", ie.
 Object fromString(String xml)
          Parse the XML representation of an instance.
 int getColumnSpan(Mapping mapping)
          How many columns are used to persist this type.
 String getName()
          Returns the abbreviated name of the type.
 String[] getPropertyNames()
           
 Object getPropertyValue(Object component, int i)
           
 Object getPropertyValue(Object component, int i, SessionImplementor session)
           
 Object[] getPropertyValues(Object component)
          Optional operation
 Object[] getPropertyValues(Object component, SessionImplementor session)
           
 Class getReturnedClass()
          The class returned by nullSafeGet() methods.
 Type[] getSubtypes()
           
 int hashCode()
           
 boolean hasNiceEquals()
          Does this type implement a well-behaved equals() method.
 Object instantiate()
           
 boolean isComponentType()
          Is this type a component type.
 boolean isDirty(Object x, Object y, SessionImplementor session)
          Should the parent be considered dirty, given both the old and current field or element value?
 boolean isMutable()
          Are objects of this type mutable.
 Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
          Retrieve an instance of the mapped class from a JDBC resultset.
 Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
          Retrieve an instance of the mapped class from a JDBC resultset.
 void nullSafeSet(PreparedStatement st, Object value, int begin, SessionImplementor session)
          Write an instance of the mapped class to a prepared statement.
 void setPropertyValues(Object component, Object[] values)
          Optional operation
 int[] sqlTypes(Mapping mapping)
          Return the SQL type codes for the columns mapped by this type.
 String toString(Object value, SessionFactoryImplementor factory)
          A representation of the value to be embedded in an XML element.
 
Methods inherited from class net.sf.hibernate.type.AbstractType
assemble, disassemble, hydrate, isAssociationType, isEntityType, isModified, isObjectType, isPersistentCollectionType, resolveIdentifier
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.hibernate.type.Type
assemble, disassemble, hydrate, isAssociationType, isEntityType, isModified, isObjectType, isPersistentCollectionType, resolveIdentifier
 

Constructor Detail

DynamicComponentType

public DynamicComponentType(String[] propertyNames,
                            Type[] propertyTypes,
                            int[] joinedFetch,
                            Cascades.CascadeStyle[] cascade)
Method Detail

cascade

public Cascades.CascadeStyle cascade(int i)
Specified by:
cascade in interface AbstractComponentType

enableJoinedFetch

public int enableJoinedFetch(int i)
Specified by:
enableJoinedFetch in interface AbstractComponentType

getPropertyNames

public String[] getPropertyNames()
Specified by:
getPropertyNames in interface AbstractComponentType

getPropertyValue

public Object getPropertyValue(Object component,
                               int i,
                               SessionImplementor session)
                        throws HibernateException
Specified by:
getPropertyValue in interface AbstractComponentType
Throws:
HibernateException

getPropertyValues

public Object[] getPropertyValues(Object component,
                                  SessionImplementor session)
                           throws HibernateException
Specified by:
getPropertyValues in interface AbstractComponentType
Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object component,
                               int i)
                        throws HibernateException
Throws:
HibernateException

getPropertyValues

public Object[] getPropertyValues(Object component)
                           throws HibernateException
Description copied from interface: AbstractComponentType
Optional operation

Specified by:
getPropertyValues in interface AbstractComponentType
Throws:
HibernateException

getSubtypes

public Type[] getSubtypes()
Specified by:
getSubtypes in interface AbstractComponentType

instantiate

public Object instantiate()
                   throws HibernateException
Throws:
HibernateException

setPropertyValues

public void setPropertyValues(Object component,
                              Object[] values)
                       throws HibernateException
Description copied from interface: AbstractComponentType
Optional operation

Specified by:
setPropertyValues in interface AbstractComponentType
Throws:
HibernateException

deepCopy

public Object deepCopy(Object component)
                throws HibernateException
Description copied from interface: Type
Return a deep copy of the persistent state, stopping at entities and at collections.

Specified by:
deepCopy in interface Type
Parameters:
component - generally a collection element or entity field
Returns:
Object a copy
Throws:
HibernateException

copy

public Object copy(Object original,
                   Object target,
                   SessionImplementor session,
                   Object owner,
                   Map copiedAlready)
            throws HibernateException
Specified by:
copy in interface Type
Overrides:
copy in class AbstractType
Throws:
HibernateException

equals

public boolean equals(Object x,
                      Object y)
               throws HibernateException
Description copied from interface: Type
Compare two instances of the class mapped by this type for persistence "equality", ie. Equality of persistent state.

Specified by:
equals in interface Type
Parameters:
x -
y -
Returns:
boolean
Throws:
HibernateException

isDirty

public boolean isDirty(Object x,
                       Object y,
                       SessionImplementor session)
                throws HibernateException
Description copied from interface: Type
Should the parent be considered dirty, given both the old and current field or element value?

Specified by:
isDirty in interface Type
Overrides:
isDirty in class AbstractType
Throws:
HibernateException

getColumnSpan

public int getColumnSpan(Mapping mapping)
                  throws MappingException
Description copied from interface: Type
How many columns are used to persist this type.

Specified by:
getColumnSpan in interface Type
Throws:
MappingException

getName

public String getName()
Description copied from interface: Type
Returns the abbreviated name of the type.

Specified by:
getName in interface Type
Returns:
String the Hibernate type name

hasNiceEquals

public boolean hasNiceEquals()
Description copied from interface: Type
Does this type implement a well-behaved equals() method. (ie. one that is consistent with Type.equals().) Strictly, if this method returns true then x.equals(y) implies Type.equals(x, y) and also Type.equals(x, y) implies that probably x.equals(y)

Specified by:
hasNiceEquals in interface Type
See Also:
Object.equals(java.lang.Object), Type.equals(java.lang.Object, java.lang.Object)

isMutable

public boolean isMutable()
Description copied from interface: Type
Are objects of this type mutable. (With respect to the referencing object ... entities and collections are considered immutable because they manage their own internal state.)

Specified by:
isMutable in interface Type
Returns:
boolean

nullSafeGet

public Object nullSafeGet(ResultSet rs,
                          String name,
                          SessionImplementor session,
                          Object owner)
                   throws HibernateException,
                          SQLException
Description copied from interface: Type
Retrieve an instance of the mapped class from a JDBC resultset. Implementations should handle possibility of null values. This method might be called if the type is known to be a single-column type.

Specified by:
nullSafeGet in interface Type
Parameters:
rs -
name - the column name
session -
owner - the parent entity
Returns:
Object
Throws:
SQLException
HibernateException

nullSafeGet

public Object nullSafeGet(ResultSet rs,
                          String[] names,
                          SessionImplementor session,
                          Object owner)
                   throws HibernateException,
                          SQLException
Description copied from interface: Type
Retrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.

Specified by:
nullSafeGet in interface Type
Parameters:
rs -
names - the column names
session -
owner - the parent entity
Returns:
Object
Throws:
HibernateException
SQLException
See Also:
alternative, 2-phase property initialization

nullSafeSet

public void nullSafeSet(PreparedStatement st,
                        Object value,
                        int begin,
                        SessionImplementor session)
                 throws HibernateException,
                        SQLException
Description copied from interface: Type
Write an instance of the mapped class to a prepared statement. Implementors should handle possibility of null values. A multi-column type should be written to parameters starting from index.

Specified by:
nullSafeSet in interface Type
Parameters:
st -
value - the object to write
begin - statement parameter index
session -
Throws:
SQLException
HibernateException

getReturnedClass

public Class getReturnedClass()
Description copied from interface: Type
The class returned by nullSafeGet() methods. This is used to establish the class of an array of this type.

Specified by:
getReturnedClass in interface Type
Returns:
Class

sqlTypes

public int[] sqlTypes(Mapping mapping)
               throws MappingException
Description copied from interface: Type
Return the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.

Specified by:
sqlTypes in interface Type
Returns:
the typecodes
Throws:
MappingException
See Also:
Types

toString

public String toString(Object value,
                       SessionFactoryImplementor factory)
                throws HibernateException
Description copied from interface: Type
A representation of the value to be embedded in an XML element.

Specified by:
toString in interface Type
Parameters:
value -
factory -
Returns:
String
Throws:
HibernateException

equals

public boolean equals(Object object)
Overrides:
equals in class AbstractType

fromString

public Object fromString(String xml)
                  throws HibernateException
Description copied from interface: Type
Parse the XML representation of an instance.

Specified by:
fromString in interface Type
Parameters:
xml -
Returns:
an instance of the type
Throws:
HibernateException

isComponentType

public boolean isComponentType()
Description copied from interface: Type
Is this type a component type. If so, the implementation must be castable to AbstractComponentType. A component type may own collections or associations and hence must provide certain extra functionality.

Specified by:
isComponentType in interface Type
Overrides:
isComponentType in class AbstractType

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractType