Methods Summary |
---|
public void | afterInitialize(java.lang.Object entity, boolean lazyPropertiesAreUnfetched, org.hibernate.engine.SessionImplementor session)
|
protected abstract org.hibernate.tuple.Instantiator | buildInstantiator(org.hibernate.mapping.PersistentClass mappingInfo)Build an appropriate Instantiator for the given mapped entity.
|
protected abstract org.hibernate.property.Getter | buildPropertyGetter(org.hibernate.mapping.Property mappedProperty, org.hibernate.mapping.PersistentClass mappedEntity)Build an appropriate Getter for the given property.
|
protected abstract org.hibernate.property.Setter | buildPropertySetter(org.hibernate.mapping.Property mappedProperty, org.hibernate.mapping.PersistentClass mappedEntity)Build an appropriate Setter for the given property.
|
protected abstract org.hibernate.proxy.ProxyFactory | buildProxyFactory(org.hibernate.mapping.PersistentClass mappingInfo, org.hibernate.property.Getter idGetter, org.hibernate.property.Setter idSetter)Build an appropriate ProxyFactory for the given mapped entity.
|
public final java.lang.Object | createProxy(java.io.Serializable id, org.hibernate.engine.SessionImplementor session)
return getProxyFactory().getProxy( id, session );
|
protected java.lang.Object | getComponentValue(org.hibernate.type.ComponentType type, java.lang.Object component, java.lang.String propertyPath)Extract a component property value.
int loc = propertyPath.indexOf('.");
String basePropertyName = loc>0 ?
propertyPath.substring(0, loc) : propertyPath;
String[] propertyNames = type.getPropertyNames();
int index=0;
for ( ; index<propertyNames.length; index++ ) {
if ( basePropertyName.equals( propertyNames[index] ) ) break;
}
if (index==propertyNames.length) {
throw new MappingException( "component property not found: " + basePropertyName );
}
Object baseValue = type.getPropertyValue( component, index, getEntityMode() );
if ( loc>0 ) {
ComponentType subtype = (ComponentType) type.getSubtypes()[index];
return getComponentValue( subtype, baseValue, propertyPath.substring(loc+1) );
}
else {
return baseValue;
}
|
protected final EntityMetamodel | getEntityMetamodel()
return entityMetamodel;
|
protected abstract org.hibernate.EntityMode | getEntityMode()Return the entity-mode handled by this tuplizer instance.
|
protected java.lang.String | getEntityName()Retreives the defined entity-name for the tuplized entity.
return entityMetamodel.getName();
|
protected final org.hibernate.engine.SessionFactoryImplementor | getFactory()
return entityMetamodel.getSessionFactory();
|
public java.io.Serializable | getIdentifier(java.lang.Object entity)
final Object id;
if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
id = entity;
}
else {
if ( idGetter == null ) {
if (identifierMapperType==null) {
throw new HibernateException( "The class has no identifier property: " + getEntityName() );
}
else {
ComponentType copier = (ComponentType) entityMetamodel.getIdentifierProperty().getType();
id = copier.instantiate( getEntityMode() );
copier.setPropertyValues( id, identifierMapperType.getPropertyValues( entity, getEntityMode() ), getEntityMode() );
}
}
else {
id = idGetter.get( entity );
}
}
try {
return (Serializable) id;
}
catch ( ClassCastException cce ) {
StringBuffer msg = new StringBuffer( "Identifier classes must be serializable. " );
if ( id != null ) {
msg.append( id.getClass().getName() + " is not serializable. " );
}
if ( cce.getMessage() != null ) {
msg.append( cce.getMessage() );
}
throw new ClassCastException( msg.toString() );
}
|
protected final org.hibernate.tuple.Instantiator | getInstantiator()
return instantiator;
|
public java.lang.Object | getPropertyValue(java.lang.Object entity, int i)
return getters[i].get( entity );
|
public java.lang.Object | getPropertyValue(java.lang.Object entity, java.lang.String propertyPath)
int loc = propertyPath.indexOf('.");
String basePropertyName = loc>0 ?
propertyPath.substring(0, loc) : propertyPath;
int index = entityMetamodel.getPropertyIndex( basePropertyName );
Object baseValue = getPropertyValue( entity, index );
if ( loc>0 ) {
ComponentType type = (ComponentType) entityMetamodel.getPropertyTypes()[index];
return getComponentValue( type, baseValue, propertyPath.substring(loc+1) );
}
else {
return baseValue;
}
|
public java.lang.Object[] | getPropertyValues(java.lang.Object entity)
boolean getAll = shouldGetAllProperties( entity );
final int span = entityMetamodel.getPropertySpan();
final Object[] result = new Object[span];
for ( int j = 0; j < span; j++ ) {
StandardProperty property = entityMetamodel.getProperties()[j];
if ( getAll || !property.isLazy() ) {
result[j] = getters[j].get( entity );
}
else {
result[j] = LazyPropertyInitializer.UNFETCHED_PROPERTY;
}
}
return result;
|
public java.lang.Object[] | getPropertyValuesToInsert(java.lang.Object entity, java.util.Map mergeMap, org.hibernate.engine.SessionImplementor session)
final int span = entityMetamodel.getPropertySpan();
final Object[] result = new Object[span];
for ( int j = 0; j < span; j++ ) {
result[j] = getters[j].getForInsert( entity, mergeMap, session );
}
return result;
|
protected final org.hibernate.proxy.ProxyFactory | getProxyFactory()
return proxyFactory;
|
protected java.util.Set | getSubclassEntityNames()Retreives the defined entity-names for any subclasses defined for this
entity.
return entityMetamodel.getSubclassEntityNames();
|
public java.lang.Object | getVersion(java.lang.Object entity)
if ( !entityMetamodel.isVersioned() ) return null;
return getters[ entityMetamodel.getVersionPropertyIndex() ].get( entity );
|
public boolean | hasProxy()
return entityMetamodel.isLazy();
|
public boolean | hasUninitializedLazyProperties(java.lang.Object entity)
// the default is to simply not lazy fetch properties for now...
return false;
|
public final java.lang.Object | instantiate(java.io.Serializable id)
Object result = getInstantiator().instantiate( id );
if ( id != null ) {
setIdentifier( result, id );
}
return result;
|
public final java.lang.Object | instantiate()
return instantiate( null );
|
public final boolean | isInstance(java.lang.Object object)
return getInstantiator().isInstance( object );
|
public boolean | isLifecycleImplementor()
return false;
|
public boolean | isValidatableImplementor()
return false;
|
public void | resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion)
if ( entityMetamodel.getIdentifierProperty().getIdentifierGenerator() instanceof Assigned ) {
//return currentId;
}
else {
//reset the id
Serializable result = entityMetamodel.getIdentifierProperty()
.getUnsavedValue()
.getDefaultValue( currentId );
setIdentifier( entity, result );
//reset the version
VersionProperty versionProperty = entityMetamodel.getVersionProperty();
if ( entityMetamodel.isVersioned() ) {
setPropertyValue(
entity,
entityMetamodel.getVersionPropertyIndex(),
versionProperty.getUnsavedValue().getDefaultValue( currentVersion )
);
}
//return the id, so we can use it to reset the proxy id
//return result;
}
|
public void | setIdentifier(java.lang.Object entity, java.io.Serializable id)
if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
if ( entity != id ) {
AbstractComponentType copier = (AbstractComponentType) entityMetamodel.getIdentifierProperty().getType();
copier.setPropertyValues( entity, copier.getPropertyValues( id, getEntityMode() ), getEntityMode() );
}
}
else if ( idSetter != null ) {
idSetter.set( entity, id, getFactory() );
}
|
public void | setPropertyValue(java.lang.Object entity, int i, java.lang.Object value)
setters[i].set( entity, value, getFactory() );
|
public void | setPropertyValue(java.lang.Object entity, java.lang.String propertyName, java.lang.Object value)
setters[ entityMetamodel.getPropertyIndex( propertyName ) ].set( entity, value, getFactory() );
|
public void | setPropertyValues(java.lang.Object entity, java.lang.Object[] values)
boolean setAll = !entityMetamodel.hasLazyProperties();
for ( int j = 0; j < entityMetamodel.getPropertySpan(); j++ ) {
if ( setAll || values[j] != LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
setters[j].set( entity, values[j], getFactory() );
}
}
|
protected boolean | shouldGetAllProperties(java.lang.Object entity)
return !hasUninitializedLazyProperties( entity );
|
public java.lang.String | toString()
return getClass().getName() + '(" + getEntityMetamodel().getName() + ')";
|