| Method from org.hibernate.tuple.entity.AbstractEntityTuplizer Detail: |
public void afterInitialize(Object entity,
boolean lazyPropertiesAreUnfetched,
SessionImplementor session) {
}
|
abstract protected Instantiator buildInstantiator(PersistentClass mappingInfo)
Build an appropriate Instantiator for the given mapped entity. |
abstract protected Getter buildPropertyGetter(Property mappedProperty,
PersistentClass mappedEntity)
Build an appropriate Getter for the given property. |
abstract protected Setter buildPropertySetter(Property mappedProperty,
PersistentClass mappedEntity)
Build an appropriate Setter for the given property. |
abstract protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo,
Getter idGetter,
Setter idSetter)
Build an appropriate ProxyFactory for the given mapped entity. |
public final Object createProxy(Serializable id,
SessionImplementor session) throws HibernateException {
return getProxyFactory().getProxy( id, session );
}
|
protected Object getComponentValue(ComponentType type,
Object component,
String propertyPath) {
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;
}
}
Extract a component property value. |
protected final EntityMetamodel getEntityMetamodel() {
return entityMetamodel;
}
|
abstract protected EntityMode getEntityMode()
Return the entity-mode handled by this tuplizer instance. |
protected String getEntityName() {
return entityMetamodel.getName();
}
Retreives the defined entity-name for the tuplized entity. |
protected final SessionFactoryImplementor getFactory() {
return entityMetamodel.getSessionFactory();
}
|
public Serializable getIdentifier(Object entity) throws HibernateException {
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 Instantiator getInstantiator() {
return instantiator;
}
|
public Object getPropertyValue(Object entity,
int i) throws HibernateException {
return getters[i].get( entity );
}
|
public Object getPropertyValue(Object entity,
String propertyPath) throws HibernateException {
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 Object[] getPropertyValues(Object entity) throws HibernateException {
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 Object[] getPropertyValuesToInsert(Object entity,
Map mergeMap,
SessionImplementor session) throws HibernateException {
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 ProxyFactory getProxyFactory() {
return proxyFactory;
}
|
protected Set getSubclassEntityNames() {
return entityMetamodel.getSubclassEntityNames();
}
Retreives the defined entity-names for any subclasses defined for this
entity. |
public Object getVersion(Object entity) throws HibernateException {
if ( !entityMetamodel.isVersioned() ) return null;
return getters[ entityMetamodel.getVersionPropertyIndex() ].get( entity );
}
|
public boolean hasProxy() {
return entityMetamodel.isLazy();
}
|
public boolean hasUninitializedLazyProperties(Object entity) {
// the default is to simply not lazy fetch properties for now...
return false;
}
|
public final Object instantiate() throws HibernateException {
return instantiate( null );
}
|
public final Object instantiate(Serializable id) throws HibernateException {
Object result = getInstantiator().instantiate( id );
if ( id != null ) {
setIdentifier( result, id );
}
return result;
}
|
public final boolean isInstance(Object object) {
return getInstantiator().isInstance( object );
}
|
public boolean isLifecycleImplementor() {
return false;
}
|
public boolean isValidatableImplementor() {
return false;
}
|
public void resetIdentifier(Object entity,
Serializable currentId,
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(Object entity,
Serializable id) throws HibernateException {
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(Object entity,
int i,
Object value) throws HibernateException {
setters[i].set( entity, value, getFactory() );
}
|
public void setPropertyValue(Object entity,
String propertyName,
Object value) throws HibernateException {
setters[ entityMetamodel.getPropertyIndex( propertyName ) ].set( entity, value, getFactory() );
}
|
public void setPropertyValues(Object entity,
Object[] values) throws HibernateException {
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(Object entity) {
return !hasUninitializedLazyProperties( entity );
}
|
public String toString() {
return getClass().getName() + '(" + getEntityMetamodel().getName() + ')";
}
|