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

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


net.sf.hibernate.type
Class EntityType

java.lang.Object
  extended bynet.sf.hibernate.type.AbstractType
      extended bynet.sf.hibernate.type.EntityType
All Implemented Interfaces:
AssociationType, Serializable, Type
Direct Known Subclasses:
ManyToOneType, OneToOneType

public abstract class EntityType
extends AbstractType
implements AssociationType

A reference to an entity class

Author:
Gavin King
See Also:
Serialized Form

Field Summary
protected  String uniqueKeyPropertyName
           
 
Constructor Summary
protected EntityType(Class persistentClass, String uniqueKeyPropertyName)
           
 
Method Summary
 Object copy(Object original, Object target, SessionImplementor session, Object owner, Map copiedAlready)
           
 Object deepCopy(Object value)
          Return a deep copy of the persistent state, stopping at entities and at collections.
 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.
 Class getAssociatedClass()
           
 Class getAssociatedClass(SessionFactoryImplementor factory)
           
protected  Object getIdentifier(Object value, SessionImplementor session)
           
 String getIdentifierOrUniqueKeyPropertyName(SessionFactoryImplementor factory)
           
 Type getIdentifierOrUniqueKeyType(SessionFactoryImplementor factory)
           
 Joinable getJoinable(SessionFactoryImplementor factory)
          Get the "persister" for this association - a class or collection persister
 String getName()
          Returns the abbreviated name of the type.
 Class getPersistentClass()
          Deprecated. use getAssociationClass()
 String[] getReferencedColumns(SessionFactoryImplementor factory)
          Get the columns referenced by this association.
 Class getReturnedClass()
          This returns the wrong class for an entity with a proxy.
 int hashCode()
           
 boolean hasNiceEquals()
          Does this type implement a well-behaved equals() method.
abstract  Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
          Retrieve an instance of the mapped class, or the identifier of an entity or collection, from a JDBC resultset.
 boolean isAssociationType()
          Return true if the implementation is castable to AssociationType.
 boolean isDirty(Object old, Object current, SessionImplementor session)
          Should the parent be considered dirty, given both the old and current field or element value?
 boolean isEntityType()
          Is this type an entity type?
 boolean isMutable()
          Are objects of this type mutable.
abstract  boolean isOneToOne()
           
 boolean isUniqueKeyReference()
           
 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.
 Object resolveIdentifier(Object value, SessionImplementor session, Object owner)
          Resolve an identifier or unique key value
protected abstract  Object resolveIdentifier(Serializable id, SessionImplementor session)
          Resolve an identifier
 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, isComponentType, isModified, isObjectType, isPersistentCollectionType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.hibernate.type.AssociationType
getForeignKeyDirection, usePrimaryKeyAsForeignKey
 
Methods inherited from interface net.sf.hibernate.type.Type
assemble, disassemble, getColumnSpan, isComponentType, isModified, isObjectType, isPersistentCollectionType, nullSafeSet, sqlTypes
 

Field Detail

uniqueKeyPropertyName

protected final String uniqueKeyPropertyName
Constructor Detail

EntityType

protected EntityType(Class persistentClass,
                     String uniqueKeyPropertyName)
Method Detail

isEntityType

public final boolean isEntityType()
Description copied from interface: Type
Is this type an entity type?

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

getAssociatedClass

public final Class getAssociatedClass()

equals

public final boolean equals(Object x,
                            Object y)
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

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

getReturnedClass

public final Class getReturnedClass()
This returns the wrong class for an entity with a proxy. Theoretically it should return the proxy class, but it doesn't.

Specified by:
getReturnedClass in interface Type
Returns:
Class

getIdentifier

protected final Object getIdentifier(Object value,
                                     SessionImplementor session)
                              throws HibernateException
Throws:
HibernateException

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

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

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

deepCopy

public Object deepCopy(Object value)
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:
value - generally a collection element or entity field
Returns:
Object a copy

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

isOneToOne

public abstract boolean isOneToOne()

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

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)

isAssociationType

public boolean isAssociationType()
Description copied from interface: Type
Return true if the implementation is castable to AssociationType. This does not necessarily imply that the type actually represents an association.

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

nullSafeGet

public final 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

hydrate

public abstract Object hydrate(ResultSet rs,
                               String[] names,
                               SessionImplementor session,
                               Object owner)
                        throws HibernateException,
                               SQLException
Description copied from interface: Type
Retrieve an instance of the mapped class, or the identifier of an entity or collection, from a JDBC resultset. This is useful for 2-phase property initialization - the second phase is a call to resolveIdentifier().

Specified by:
hydrate in interface Type
Overrides:
hydrate in class AbstractType
Throws:
HibernateException
SQLException

isDirty

public boolean isDirty(Object old,
                       Object current,
                       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

isUniqueKeyReference

public boolean isUniqueKeyReference()

getJoinable

public Joinable getJoinable(SessionFactoryImplementor factory)
                     throws MappingException
Description copied from interface: AssociationType
Get the "persister" for this association - a class or collection persister

Specified by:
getJoinable in interface AssociationType
Throws:
MappingException

getReferencedColumns

public String[] getReferencedColumns(SessionFactoryImplementor factory)
                              throws MappingException
Description copied from interface: AssociationType
Get the columns referenced by this association.

Specified by:
getReferencedColumns in interface AssociationType
Throws:
MappingException

getIdentifierOrUniqueKeyType

public final Type getIdentifierOrUniqueKeyType(SessionFactoryImplementor factory)
                                        throws MappingException
Throws:
MappingException

getIdentifierOrUniqueKeyPropertyName

public final String getIdentifierOrUniqueKeyPropertyName(SessionFactoryImplementor factory)
                                                  throws MappingException
Throws:
MappingException

resolveIdentifier

protected abstract Object resolveIdentifier(Serializable id,
                                            SessionImplementor session)
                                     throws HibernateException
Resolve an identifier

Throws:
HibernateException

resolveIdentifier

public Object resolveIdentifier(Object value,
                                SessionImplementor session,
                                Object owner)
                         throws HibernateException
Resolve an identifier or unique key value

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

getAssociatedClass

public Class getAssociatedClass(SessionFactoryImplementor factory)
Specified by:
getAssociatedClass in interface AssociationType

getPersistentClass

public Class getPersistentClass()
Deprecated. use getAssociationClass()


equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractType