HHH-7919 : Miscellaneous bugfixes
This commit is contained in:
parent
21c3a17d4c
commit
da40234ab7
|
@ -45,6 +45,7 @@ public interface Mapping {
|
||||||
*
|
*
|
||||||
* @deprecated temporary solution
|
* @deprecated temporary solution
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public IdentifierGeneratorFactory getIdentifierGeneratorFactory();
|
public IdentifierGeneratorFactory getIdentifierGeneratorFactory();
|
||||||
public Type getIdentifierType(String className) throws MappingException;
|
public Type getIdentifierType(String className) throws MappingException;
|
||||||
public String getIdentifierPropertyName(String className) throws MappingException;
|
public String getIdentifierPropertyName(String className) throws MappingException;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -95,7 +95,7 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
||||||
@Override
|
@Override
|
||||||
public IdentifierSource getIdentifierSource() {
|
public IdentifierSource getIdentifierSource() {
|
||||||
if ( entityElement().getId() == null && entityElement().getCompositeId() == null ) {
|
if ( entityElement().getId() == null && entityElement().getCompositeId() == null ) {
|
||||||
throw new AssertionFailure(
|
throw makeMappingException(
|
||||||
String.format( "Entity [%s] did not define an identifier", getEntityName() )
|
String.format( "Entity [%s] did not define an identifier", getEntityName() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -675,6 +675,7 @@ public interface EntityPersister extends OptimisticCacheSource, EntityDefinition
|
||||||
* @deprecated Use {@link #getIdentifier(Object,SessionImplementor)} instead
|
* @deprecated Use {@link #getIdentifier(Object,SessionImplementor)} instead
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings( {"JavaDoc"})
|
@SuppressWarnings( {"JavaDoc"})
|
||||||
|
@Deprecated
|
||||||
public Serializable getIdentifier(Object object) throws HibernateException;
|
public Serializable getIdentifier(Object object) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,9 +57,7 @@ public class ComponentMetamodel implements Serializable {
|
||||||
private final int propertySpan;
|
private final int propertySpan;
|
||||||
private final Map<String,Integer> propertyIndexes = new HashMap<String,Integer>();
|
private final Map<String,Integer> propertyIndexes = new HashMap<String,Integer>();
|
||||||
|
|
||||||
// public ComponentMetamodel(Component component, SessionFactoryImplementor sessionFactory) {
|
|
||||||
public ComponentMetamodel(Component component) {
|
public ComponentMetamodel(Component component) {
|
||||||
// this.sessionFactory = sessionFactory;
|
|
||||||
this.isKey = component.isKey();
|
this.isKey = component.isKey();
|
||||||
propertySpan = component.getPropertySpan();
|
propertySpan = component.getPropertySpan();
|
||||||
properties = new StandardProperty[propertySpan];
|
properties = new StandardProperty[propertySpan];
|
||||||
|
|
|
@ -402,14 +402,14 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
this.virtualIdComponent = virtualIdComponent;
|
this.virtualIdComponent = virtualIdComponent;
|
||||||
this.mappedIdentifierType = mappedIdentifierType;
|
this.mappedIdentifierType = mappedIdentifierType;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object getIdentifier(Object entity, EntityMode entityMode, SessionImplementor session) {
|
public Object getIdentifier(Object entity, EntityMode entityMode, SessionImplementor session) {
|
||||||
Object id = mappedIdentifierType.instantiate( entityMode );
|
Object id = mappedIdentifierType.instantiate( entityMode );
|
||||||
final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
|
final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
|
||||||
mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode );
|
mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode );
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SessionImplementor session) {
|
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SessionImplementor session) {
|
||||||
virtualIdComponent.setPropertyValues(
|
virtualIdComponent.setPropertyValues(
|
||||||
entity,
|
entity,
|
||||||
|
@ -427,7 +427,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
this.virtualIdComponent = virtualIdComponent;
|
this.virtualIdComponent = virtualIdComponent;
|
||||||
this.mappedIdentifierType = mappedIdentifierType;
|
this.mappedIdentifierType = mappedIdentifierType;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object getIdentifier(Object entity, EntityMode entityMode, SessionImplementor session) {
|
public Object getIdentifier(Object entity, EntityMode entityMode, SessionImplementor session) {
|
||||||
final Object id = mappedIdentifierType.instantiate( entityMode );
|
final Object id = mappedIdentifierType.instantiate( entityMode );
|
||||||
final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
|
final Object[] propertyValues = virtualIdComponent.getPropertyValues( entity, entityMode );
|
||||||
|
@ -478,7 +478,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode );
|
mappedIdentifierType.setPropertyValues( id, propertyValues, entityMode );
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SessionImplementor session) {
|
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SessionImplementor session) {
|
||||||
final Object[] extractedValues = mappedIdentifierType.getPropertyValues( id, entityMode );
|
final Object[] extractedValues = mappedIdentifierType.getPropertyValues( id, entityMode );
|
||||||
final Object[] injectionValues = new Object[ extractedValues.length ];
|
final Object[] injectionValues = new Object[ extractedValues.length ];
|
||||||
|
@ -521,9 +521,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
.getEventListenerGroup( EventType.PERSIST )
|
.getEventListenerGroup( EventType.PERSIST )
|
||||||
.listeners();
|
.listeners();
|
||||||
}
|
}
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void resetIdentifier(
|
public void resetIdentifier(
|
||||||
Object entity,
|
Object entity,
|
||||||
Serializable currentId,
|
Serializable currentId,
|
||||||
|
@ -548,7 +546,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object getVersion(Object entity) throws HibernateException {
|
public Object getVersion(Object entity) throws HibernateException {
|
||||||
if ( !entityMetamodel.isVersioned() ) return null;
|
if ( !entityMetamodel.isVersioned() ) return null;
|
||||||
return getters[ entityMetamodel.getVersionPropertyIndex() ].get( entity );
|
return getters[ entityMetamodel.getVersionPropertyIndex() ].get( entity );
|
||||||
|
@ -557,7 +555,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
protected boolean shouldGetAllProperties(Object entity) {
|
protected boolean shouldGetAllProperties(Object entity) {
|
||||||
return !hasUninitializedLazyProperties( entity );
|
return !hasUninitializedLazyProperties( entity );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object[] getPropertyValues(Object entity) throws HibernateException {
|
public Object[] getPropertyValues(Object entity) throws HibernateException {
|
||||||
boolean getAll = shouldGetAllProperties( entity );
|
boolean getAll = shouldGetAllProperties( entity );
|
||||||
final int span = entityMetamodel.getPropertySpan();
|
final int span = entityMetamodel.getPropertySpan();
|
||||||
|
@ -574,7 +572,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session)
|
public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
final int span = entityMetamodel.getPropertySpan();
|
final int span = entityMetamodel.getPropertySpan();
|
||||||
|
@ -585,11 +583,11 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object getPropertyValue(Object entity, int i) throws HibernateException {
|
public Object getPropertyValue(Object entity, int i) throws HibernateException {
|
||||||
return getters[i].get( entity );
|
return getters[i].get( entity );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object getPropertyValue(Object entity, String propertyPath) throws HibernateException {
|
public Object getPropertyValue(Object entity, String propertyPath) throws HibernateException {
|
||||||
int loc = propertyPath.indexOf('.');
|
int loc = propertyPath.indexOf('.');
|
||||||
String basePropertyName = loc > 0
|
String basePropertyName = loc > 0
|
||||||
|
@ -670,7 +668,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
throw new MappingException( "component property not found: " + subPropertyName );
|
throw new MappingException( "component property not found: " + subPropertyName );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setPropertyValues(Object entity, Object[] values) throws HibernateException {
|
public void setPropertyValues(Object entity, Object[] values) throws HibernateException {
|
||||||
boolean setAll = !entityMetamodel.hasLazyProperties();
|
boolean setAll = !entityMetamodel.hasLazyProperties();
|
||||||
|
|
||||||
|
@ -680,15 +678,15 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setPropertyValue(Object entity, int i, Object value) throws HibernateException {
|
public void setPropertyValue(Object entity, int i, Object value) throws HibernateException {
|
||||||
setters[i].set( entity, value, getFactory() );
|
setters[i].set( entity, value, getFactory() );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setPropertyValue(Object entity, String propertyName, Object value) throws HibernateException {
|
public void setPropertyValue(Object entity, String propertyName, Object value) throws HibernateException {
|
||||||
setters[ entityMetamodel.getPropertyIndex( propertyName ) ].set( entity, value, getFactory() );
|
setters[ entityMetamodel.getPropertyIndex( propertyName ) ].set( entity, value, getFactory() );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object instantiate(Serializable id, SessionImplementor session) {
|
public final Object instantiate(Serializable id, SessionImplementor session) {
|
||||||
Object result = getInstantiator().instantiate( id );
|
Object result = getInstantiator().instantiate( id );
|
||||||
if ( id != null ) {
|
if ( id != null ) {
|
||||||
|
@ -696,31 +694,31 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object instantiate() throws HibernateException {
|
public final Object instantiate() throws HibernateException {
|
||||||
return instantiate( null, null );
|
return instantiate( null, null );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) {}
|
public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) {}
|
||||||
|
@Override
|
||||||
public boolean hasUninitializedLazyProperties(Object entity) {
|
public boolean hasUninitializedLazyProperties(Object entity) {
|
||||||
// the default is to simply not lazy fetch properties for now...
|
// the default is to simply not lazy fetch properties for now...
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isInstance(Object object) {
|
public final boolean isInstance(Object object) {
|
||||||
return getInstantiator().isInstance( object );
|
return getInstantiator().isInstance( object );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean hasProxy() {
|
public boolean hasProxy() {
|
||||||
return entityMetamodel.isLazy();
|
return entityMetamodel.isLazy();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object createProxy(Serializable id, SessionImplementor session)
|
public final Object createProxy(Serializable id, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
return getProxyFactory().getProxy( id, session );
|
return getProxyFactory().getProxy( id, session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isLifecycleImplementor() {
|
public boolean isLifecycleImplementor() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -745,18 +743,18 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getName() + '(' + getEntityMetamodel().getName() + ')';
|
return getClass().getName() + '(' + getEntityMetamodel().getName() + ')';
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Getter getIdentifierGetter() {
|
public Getter getIdentifierGetter() {
|
||||||
return idGetter;
|
return idGetter;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Getter getVersionGetter() {
|
public Getter getVersionGetter() {
|
||||||
if ( getEntityMetamodel().isVersioned() ) {
|
if ( getEntityMetamodel().isVersioned() ) {
|
||||||
return getGetter( getEntityMetamodel().getVersionPropertyIndex() );
|
return getGetter( getEntityMetamodel().getVersionPropertyIndex() );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Getter getGetter(int i) {
|
public Getter getGetter(int i) {
|
||||||
return getters[i];
|
return getters[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,7 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
super(entityMetamodel, mappedEntity);
|
super(entityMetamodel, mappedEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public EntityMode getEntityMode() {
|
public EntityMode getEntityMode() {
|
||||||
return EntityMode.MAP;
|
return EntityMode.MAP;
|
||||||
}
|
}
|
||||||
|
@ -87,33 +85,21 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
|
protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) {
|
||||||
return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getName() );
|
return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) {
|
protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) {
|
||||||
return buildPropertyAccessor(mappedProperty).getSetter( null, mappedProperty.getName() );
|
return buildPropertyAccessor(mappedProperty).getSetter( null, mappedProperty.getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Instantiator buildInstantiator(PersistentClass mappingInfo) {
|
protected Instantiator buildInstantiator(PersistentClass mappingInfo) {
|
||||||
return new DynamicMapInstantiator( mappingInfo );
|
return new DynamicMapInstantiator( mappingInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {
|
protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) {
|
||||||
|
|
||||||
|
@ -136,33 +122,21 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
return pf;
|
return pf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Getter buildPropertyGetter(AttributeBinding mappedProperty) {
|
protected Getter buildPropertyGetter(AttributeBinding mappedProperty) {
|
||||||
return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getAttribute().getName() );
|
return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getAttribute().getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Setter buildPropertySetter(AttributeBinding mappedProperty) {
|
protected Setter buildPropertySetter(AttributeBinding mappedProperty) {
|
||||||
return buildPropertyAccessor(mappedProperty).getSetter( null, mappedProperty.getAttribute().getName() );
|
return buildPropertyAccessor(mappedProperty).getSetter( null, mappedProperty.getAttribute().getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Instantiator buildInstantiator(EntityBinding mappingInfo) {
|
protected Instantiator buildInstantiator(EntityBinding mappingInfo) {
|
||||||
return new DynamicMapInstantiator( mappingInfo );
|
return new DynamicMapInstantiator( mappingInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter) {
|
protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter) {
|
||||||
|
|
||||||
|
@ -185,37 +159,27 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
return pf;
|
return pf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getMappedClass() {
|
public Class getMappedClass() {
|
||||||
return Map.class;
|
return Map.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Class getConcreteProxyClass() {
|
public Class getConcreteProxyClass() {
|
||||||
return Map.class;
|
return Map.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public boolean isInstrumented() {
|
public boolean isInstrumented() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public EntityNameResolver[] getEntityNameResolvers() {
|
public EntityNameResolver[] getEntityNameResolvers() {
|
||||||
return new EntityNameResolver[] { BasicEntityNameResolver.INSTANCE };
|
return new EntityNameResolver[] { BasicEntityNameResolver.INSTANCE };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) {
|
public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) {
|
||||||
return extractEmbeddedEntityName( ( Map ) entityInstance );
|
return extractEmbeddedEntityName( ( Map ) entityInstance );
|
||||||
}
|
}
|
||||||
|
@ -227,9 +191,7 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
public static class BasicEntityNameResolver implements EntityNameResolver {
|
public static class BasicEntityNameResolver implements EntityNameResolver {
|
||||||
public static final BasicEntityNameResolver INSTANCE = new BasicEntityNameResolver();
|
public static final BasicEntityNameResolver INSTANCE = new BasicEntityNameResolver();
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String resolveEntityName(Object entity) {
|
public String resolveEntityName(Object entity) {
|
||||||
if ( ! Map.class.isInstance( entity ) ) {
|
if ( ! Map.class.isInstance( entity ) ) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -241,17 +203,11 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer {
|
||||||
return entityName;
|
return entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return getClass().equals( obj.getClass() );
|
return getClass().equals( obj.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getClass().hashCode();
|
return getClass().hashCode();
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public abstract class AbstractStandardBasicType<T>
|
public abstract class AbstractStandardBasicType<T>
|
||||||
implements BasicType, StringRepresentableType<T>, ProcedureParameterExtractionAware<T> {
|
implements BasicType, StringRepresentableType<T>, ProcedureParameterExtractionAware<T> {
|
||||||
|
|
||||||
|
@ -70,11 +71,11 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
public T fromString(String string) {
|
public T fromString(String string) {
|
||||||
return javaTypeDescriptor.fromString( string );
|
return javaTypeDescriptor.fromString( string );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String toString(T value) {
|
public String toString(T value) {
|
||||||
return javaTypeDescriptor.toString( value );
|
return javaTypeDescriptor.toString( value );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public T fromStringValue(String xml) throws HibernateException {
|
public T fromStringValue(String xml) throws HibernateException {
|
||||||
return fromString( xml );
|
return fromString( xml );
|
||||||
}
|
}
|
||||||
|
@ -94,11 +95,11 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
return deepCopy( original );
|
return deepCopy( original );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
||||||
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String[] getRegistrationKeys() {
|
public String[] getRegistrationKeys() {
|
||||||
return registerUnderJavaType()
|
return registerUnderJavaType()
|
||||||
? new String[] { getName(), javaTypeDescriptor.getJavaTypeClass().getName() }
|
? new String[] { getName(), javaTypeDescriptor.getJavaTypeClass().getName() }
|
||||||
|
@ -134,15 +135,15 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
public final void setSqlTypeDescriptor( SqlTypeDescriptor sqlTypeDescriptor ) {
|
public final void setSqlTypeDescriptor( SqlTypeDescriptor sqlTypeDescriptor ) {
|
||||||
this.sqlTypeDescriptor = sqlTypeDescriptor;
|
this.sqlTypeDescriptor = sqlTypeDescriptor;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Class getReturnedClass() {
|
public final Class getReturnedClass() {
|
||||||
return javaTypeDescriptor.getJavaTypeClass();
|
return javaTypeDescriptor.getJavaTypeClass();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final int getColumnSpan(Mapping mapping) throws MappingException {
|
public final int getColumnSpan(Mapping mapping) throws MappingException {
|
||||||
return sqlTypes( mapping ).length;
|
return sqlTypes( mapping ).length;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final int[] sqlTypes(Mapping mapping) throws MappingException {
|
public final int[] sqlTypes(Mapping mapping) throws MappingException {
|
||||||
return new int[] { sqlTypeDescriptor.getSqlType() };
|
return new int[] { sqlTypeDescriptor.getSqlType() };
|
||||||
}
|
}
|
||||||
|
@ -156,60 +157,60 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
||||||
return new Size[] { getDefaultSize() };
|
return new Size[] { getDefaultSize() };
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isAssociationType() {
|
public final boolean isAssociationType() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isCollectionType() {
|
public final boolean isCollectionType() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isComponentType() {
|
public final boolean isComponentType() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isEntityType() {
|
public final boolean isEntityType() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isAnyType() {
|
public final boolean isAnyType() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final boolean isSame(Object x, Object y) {
|
public final boolean isSame(Object x, Object y) {
|
||||||
return isEqual( x, y );
|
return isEqual( x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) {
|
public final boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) {
|
||||||
return isEqual( x, y );
|
return isEqual( x, y );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final boolean isEqual(Object one, Object another) {
|
public final boolean isEqual(Object one, Object another) {
|
||||||
return javaTypeDescriptor.areEqual( (T) one, (T) another );
|
return javaTypeDescriptor.areEqual( (T) one, (T) another );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final int getHashCode(Object x) {
|
public final int getHashCode(Object x) {
|
||||||
return javaTypeDescriptor.extractHashCode( (T) x );
|
return javaTypeDescriptor.extractHashCode( (T) x );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final int getHashCode(Object x, SessionFactoryImplementor factory) {
|
public final int getHashCode(Object x, SessionFactoryImplementor factory) {
|
||||||
return getHashCode( x );
|
return getHashCode( x );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final int compare(Object x, Object y) {
|
public final int compare(Object x, Object y) {
|
||||||
return javaTypeDescriptor.getComparator().compare( (T) x, (T) y );
|
return javaTypeDescriptor.getComparator().compare( (T) x, (T) y );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isDirty(Object old, Object current, SessionImplementor session) {
|
public final boolean isDirty(Object old, Object current, SessionImplementor session) {
|
||||||
return isDirty( old, current );
|
return isDirty( old, current );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) {
|
public final boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) {
|
||||||
return checkable[0] && isDirty( old, current );
|
return checkable[0] && isDirty( old, current );
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
protected final boolean isDirty(Object old, Object current) {
|
protected final boolean isDirty(Object old, Object current) {
|
||||||
return !isSame( old, current );
|
return !isSame( old, current );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isModified(
|
public final boolean isModified(
|
||||||
Object oldHydratedState,
|
Object oldHydratedState,
|
||||||
Object currentState,
|
Object currentState,
|
||||||
|
@ -225,7 +226,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
SessionImplementor session) {
|
SessionImplementor session) {
|
||||||
return isDirty( oldHydratedState, currentState );
|
return isDirty( oldHydratedState, currentState );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object nullSafeGet(
|
public final Object nullSafeGet(
|
||||||
ResultSet rs,
|
ResultSet rs,
|
||||||
String[] names,
|
String[] names,
|
||||||
|
@ -233,7 +234,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
Object owner) throws SQLException {
|
Object owner) throws SQLException {
|
||||||
return nullSafeGet( rs, names[0], session );
|
return nullSafeGet( rs, names[0], session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
|
public final Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
return nullSafeGet( rs, name, session );
|
return nullSafeGet( rs, name, session );
|
||||||
|
@ -252,7 +253,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
return nullSafeGet( rs, name, session );
|
return nullSafeGet( rs, name, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final void nullSafeSet(
|
public final void nullSafeSet(
|
||||||
PreparedStatement st,
|
PreparedStatement st,
|
||||||
Object value,
|
Object value,
|
||||||
|
@ -262,7 +263,6 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
nullSafeSet( st, value, index, options );
|
nullSafeSet( st, value, index, options );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
|
||||||
protected final void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options) throws SQLException {
|
protected final void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options) throws SQLException {
|
||||||
remapSqlTypeDescriptor( options ).getBinder( javaTypeDescriptor ).bind( st, (T) value, index, options );
|
remapSqlTypeDescriptor( options ).getBinder( javaTypeDescriptor ).bind( st, (T) value, index, options );
|
||||||
}
|
}
|
||||||
|
@ -275,16 +275,16 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
nullSafeSet( st, value, index, session );
|
nullSafeSet( st, value, index, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final String toLoggableString(Object value, SessionFactoryImplementor factory) {
|
public final String toLoggableString(Object value, SessionFactoryImplementor factory) {
|
||||||
return javaTypeDescriptor.extractLoggableRepresentation( (T) value );
|
return javaTypeDescriptor.extractLoggableRepresentation( (T) value );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final boolean isMutable() {
|
public final boolean isMutable() {
|
||||||
return getMutabilityPlan().isMutable();
|
return getMutabilityPlan().isMutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final Object deepCopy(Object value, SessionFactoryImplementor factory) {
|
public final Object deepCopy(Object value, SessionFactoryImplementor factory) {
|
||||||
return deepCopy( (T) value );
|
return deepCopy( (T) value );
|
||||||
}
|
}
|
||||||
|
@ -293,41 +293,41 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
return getMutabilityPlan().deepCopy( value );
|
return getMutabilityPlan().deepCopy( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
public final Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
||||||
return getMutabilityPlan().disassemble( (T) value );
|
return getMutabilityPlan().disassemble( (T) value );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException {
|
public final Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException {
|
||||||
return getMutabilityPlan().assemble( cached );
|
return getMutabilityPlan().assemble( cached );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final void beforeAssemble(Serializable cached, SessionImplementor session) {
|
public final void beforeAssemble(Serializable cached, SessionImplementor session) {
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public final Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
return nullSafeGet( rs, names, session, owner );
|
return nullSafeGet( rs, names, session, owner );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
public final Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Object semiResolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
public final Object semiResolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public final Type getSemiResolvedType(SessionFactoryImplementor factory) {
|
public final Type getSemiResolvedType(SessionFactoryImplementor factory) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public final Object replace(Object original, Object target, SessionImplementor session, Object owner, Map copyCache) {
|
public final Object replace(Object original, Object target, SessionImplementor session, Object owner, Map copyCache) {
|
||||||
return getReplacement( (T) original, (T) target, session );
|
return getReplacement( (T) original, (T) target, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@Override
|
||||||
public Object replace(
|
public Object replace(
|
||||||
Object original,
|
Object original,
|
||||||
Object target,
|
Object target,
|
||||||
|
@ -364,15 +364,16 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
// TODO : have SessionImplementor extend WrapperOptions
|
// TODO : have SessionImplementor extend WrapperOptions
|
||||||
private WrapperOptions getOptions(final SessionImplementor session) {
|
private WrapperOptions getOptions(final SessionImplementor session) {
|
||||||
return new WrapperOptions() {
|
return new WrapperOptions() {
|
||||||
|
@Override
|
||||||
public boolean useStreamForLobBinding() {
|
public boolean useStreamForLobBinding() {
|
||||||
return Environment.useStreamsForBinary()
|
return Environment.useStreamsForBinary()
|
||||||
|| session.getFactory().getDialect().useInputStreamToInsertBlob();
|
|| session.getFactory().getDialect().useInputStreamToInsertBlob();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public LobCreator getLobCreator() {
|
public LobCreator getLobCreator() {
|
||||||
return Hibernate.getLobCreator( session );
|
return Hibernate.getLobCreator( session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
||||||
final SqlTypeDescriptor remapped = sqlTypeDescriptor.canBeRemapped()
|
final SqlTypeDescriptor remapped = sqlTypeDescriptor.canBeRemapped()
|
||||||
? session.getFactory().getDialect().remapSqlTypeDescriptor( sqlTypeDescriptor )
|
? session.getFactory().getDialect().remapSqlTypeDescriptor( sqlTypeDescriptor )
|
||||||
|
|
|
@ -61,43 +61,43 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
this.identifierType = identifierType;
|
this.identifierType = identifierType;
|
||||||
this.metaType = metaType;
|
this.metaType = metaType;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object deepCopy(Object value, SessionFactoryImplementor factory)
|
public Object deepCopy(Object value, SessionFactoryImplementor factory)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isMethodOf(Method method) {
|
public boolean isMethodOf(Method method) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isSame(Object x, Object y) throws HibernateException {
|
public boolean isSame(Object x, Object y) throws HibernateException {
|
||||||
return x==y;
|
return x==y;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int compare(Object x, Object y) {
|
public int compare(Object x, Object y) {
|
||||||
return 0; //TODO: entities CAN be compared, by PK and entity name, fix this!
|
return 0; //TODO: entities CAN be compared, by PK and entity name, fix this!
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int getColumnSpan(Mapping session)
|
public int getColumnSpan(Mapping session)
|
||||||
throws MappingException {
|
throws MappingException {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "object";
|
return "object";
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException("object is a multicolumn type");
|
throw new UnsupportedOperationException("object is a multicolumn type");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
return resolveAny(
|
return resolveAny(
|
||||||
|
@ -106,20 +106,20 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
String entityName = (String) metaType.nullSafeGet(rs, names[0], session, owner);
|
String entityName = (String) metaType.nullSafeGet(rs, names[0], session, owner);
|
||||||
Serializable id = (Serializable) identifierType.nullSafeGet(rs, names[1], session, owner);
|
Serializable id = (Serializable) identifierType.nullSafeGet(rs, names[1], session, owner);
|
||||||
return new ObjectTypeCacheEntry(entityName, id);
|
return new ObjectTypeCacheEntry(entityName, id);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object resolve(Object value, SessionImplementor session, Object owner)
|
public Object resolve(Object value, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
ObjectTypeCacheEntry holder = (ObjectTypeCacheEntry) value;
|
ObjectTypeCacheEntry holder = (ObjectTypeCacheEntry) value;
|
||||||
return resolveAny(holder.entityName, holder.id, session);
|
return resolveAny(holder.entityName, holder.id, session);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object semiResolve(Object value, SessionImplementor session, Object owner)
|
public Object semiResolve(Object value, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
throw new UnsupportedOperationException("any mappings may not form part of a property-ref");
|
throw new UnsupportedOperationException("any mappings may not form part of a property-ref");
|
||||||
|
@ -130,12 +130,12 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
return entityName==null || id==null ?
|
return entityName==null || id==null ?
|
||||||
null : session.internalLoad( entityName, id, false, false );
|
null : session.internalLoad( entityName, id, false, false );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
nullSafeSet(st, value, index, null, session);
|
nullSafeSet(st, value, index, null, session);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)
|
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
|
|
||||||
|
@ -163,11 +163,11 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
identifierType.nullSafeSet(st, id, index+1, idsettable, session);
|
identifierType.nullSafeSet(st, id, index+1, idsettable, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Class getReturnedClass() {
|
public Class getReturnedClass() {
|
||||||
return Object.class;
|
return Object.class;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
||||||
return ArrayHelper.join(
|
return ArrayHelper.join(
|
||||||
metaType.sqlTypes( mapping ),
|
metaType.sqlTypes( mapping ),
|
||||||
|
@ -190,7 +190,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
identifierType.defaultSizes( mapping )
|
identifierType.defaultSizes( mapping )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String toLoggableString(Object value, SessionFactoryImplementor factory)
|
public String toLoggableString(Object value, SessionFactoryImplementor factory)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
//TODO: terrible implementation!
|
//TODO: terrible implementation!
|
||||||
|
@ -209,7 +209,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object assemble(
|
public Object assemble(
|
||||||
Serializable cached,
|
Serializable cached,
|
||||||
SessionImplementor session,
|
SessionImplementor session,
|
||||||
|
@ -219,7 +219,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached;
|
ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached;
|
||||||
return e==null ? null : session.internalLoad(e.entityName, e.id, false, false);
|
return e==null ? null : session.internalLoad(e.entityName, e.id, false, false);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
|
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
return value==null ?
|
return value==null ?
|
||||||
|
@ -231,11 +231,11 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isAnyType() {
|
public boolean isAnyType() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object replace(
|
public Object replace(
|
||||||
Object original,
|
Object original,
|
||||||
Object target,
|
Object target,
|
||||||
|
@ -261,20 +261,21 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public CascadeStyle getCascadeStyle(int i) {
|
public CascadeStyle getCascadeStyle(int i) {
|
||||||
return CascadeStyles.NONE;
|
return CascadeStyles.NONE;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public FetchMode getFetchMode(int i) {
|
public FetchMode getFetchMode(int i) {
|
||||||
return FetchMode.SELECT;
|
return FetchMode.SELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] PROPERTY_NAMES = new String[] { "class", "id" };
|
private static final String[] PROPERTY_NAMES = { "class", "id" };
|
||||||
|
@Override
|
||||||
public String[] getPropertyNames() {
|
public String[] getPropertyNames() {
|
||||||
return PROPERTY_NAMES;
|
return PROPERTY_NAMES;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object getPropertyValue(Object component, int i, SessionImplementor session)
|
public Object getPropertyValue(Object component, int i, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
|
|
||||||
|
@ -282,7 +283,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
session.bestGuessEntityName(component) :
|
session.bestGuessEntityName(component) :
|
||||||
getIdentifier(component, session);
|
getIdentifier(component, session);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object[] getPropertyValues(Object component, SessionImplementor session)
|
public Object[] getPropertyValues(Object component, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
|
|
||||||
|
@ -297,43 +298,43 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Type[] getSubtypes() {
|
public Type[] getSubtypes() {
|
||||||
return new Type[] { metaType, identifierType };
|
return new Type[] { metaType, identifierType };
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void setPropertyValues(Object component, Object[] values, EntityMode entityMode)
|
public void setPropertyValues(Object component, Object[] values, EntityMode entityMode)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object[] getPropertyValues(Object component, EntityMode entityMode) {
|
public Object[] getPropertyValues(Object component, EntityMode entityMode) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isComponentType() {
|
public boolean isComponentType() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public ForeignKeyDirection getForeignKeyDirection() {
|
public ForeignKeyDirection getForeignKeyDirection() {
|
||||||
//return AssociationType.TO_PARENT; //this is better but causes a transient object exception...
|
//return AssociationType.TO_PARENT; //this is better but causes a transient object exception...
|
||||||
return ForeignKeyDirection.FROM_PARENT;
|
return ForeignKeyDirection.FROM_PARENT;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isAssociationType() {
|
public boolean isAssociationType() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean useLHSPrimaryKey() {
|
public boolean useLHSPrimaryKey() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) {
|
public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) {
|
||||||
throw new UnsupportedOperationException("any types do not have a unique referenced persister");
|
throw new UnsupportedOperationException("any types do not have a unique referenced persister");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session)
|
public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
if (current==null) return old!=null;
|
if (current==null) return old!=null;
|
||||||
|
@ -344,49 +345,46 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
return ( checkable[0] && !holder.entityName.equals( session.bestGuessEntityName(current) ) ) ||
|
return ( checkable[0] && !holder.entityName.equals( session.bestGuessEntityName(current) ) ) ||
|
||||||
identifierType.isModified(holder.id, getIdentifier(current, session), idcheckable, session);
|
identifierType.isModified(holder.id, getIdentifier(current, session), idcheckable, session);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getAssociatedEntityName(SessionFactoryImplementor factory)
|
public String getAssociatedEntityName(SessionFactoryImplementor factory)
|
||||||
throws MappingException {
|
throws MappingException {
|
||||||
throw new UnsupportedOperationException("any types do not have a unique referenced persister");
|
throw new UnsupportedOperationException("any types do not have a unique referenced persister");
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean[] getPropertyNullability() {
|
public boolean[] getPropertyNullability() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
|
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
|
||||||
throws MappingException {
|
throws MappingException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReferenceToPrimaryKey() {
|
@Override
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRHSUniqueKeyPropertyName() {
|
public String getRHSUniqueKeyPropertyName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getLHSPropertyName() {
|
public String getLHSPropertyName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isAlwaysDirtyChecked() {
|
public boolean isAlwaysDirtyChecked() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
||||||
boolean[] result = new boolean[ getColumnSpan(mapping) ];
|
boolean[] result = new boolean[ getColumnSpan(mapping) ];
|
||||||
if (value!=null) Arrays.fill(result, true);
|
if (value!=null) Arrays.fill(result, true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session)
|
public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
//TODO!!!
|
//TODO!!!
|
||||||
return isDirty(old, current, session);
|
return isDirty(old, current, session);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isEmbedded() {
|
public boolean isEmbedded() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ import org.hibernate.tuple.component.ComponentTuplizer;
|
||||||
*/
|
*/
|
||||||
public class ComponentType extends AbstractType implements CompositeType, ProcedureParameterExtractionAware {
|
public class ComponentType extends AbstractType implements CompositeType, ProcedureParameterExtractionAware {
|
||||||
|
|
||||||
private final TypeFactory.TypeScope typeScope;
|
|
||||||
private final String[] propertyNames;
|
private final String[] propertyNames;
|
||||||
private final Type[] propertyTypes;
|
private final Type[] propertyTypes;
|
||||||
private final boolean[] propertyNullability;
|
private final boolean[] propertyNullability;
|
||||||
|
@ -68,7 +67,6 @@ public class ComponentType extends AbstractType implements CompositeType, Proced
|
||||||
protected final ComponentTuplizer componentTuplizer;
|
protected final ComponentTuplizer componentTuplizer;
|
||||||
|
|
||||||
public ComponentType(TypeFactory.TypeScope typeScope, ComponentMetamodel metamodel) {
|
public ComponentType(TypeFactory.TypeScope typeScope, ComponentMetamodel metamodel) {
|
||||||
this.typeScope = typeScope;
|
|
||||||
// for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907)
|
// for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907)
|
||||||
this.isKey = metamodel.isKey();
|
this.isKey = metamodel.isKey();
|
||||||
this.propertySpan = metamodel.getPropertySpan();
|
this.propertySpan = metamodel.getPropertySpan();
|
||||||
|
@ -102,18 +100,28 @@ public class ComponentType extends AbstractType implements CompositeType, Proced
|
||||||
public ComponentTuplizer getComponentTuplizer() {
|
public ComponentTuplizer getComponentTuplizer() {
|
||||||
return componentTuplizer;
|
return componentTuplizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private transient int columnSpan = Integer.MIN_VALUE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(Mapping mapping) throws MappingException {
|
||||||
|
if ( columnSpan == Integer.MIN_VALUE ) {
|
||||||
int span = 0;
|
int span = 0;
|
||||||
for ( int i = 0; i < propertySpan; i++ ) {
|
for ( int i = 0; i < propertySpan; i++ ) {
|
||||||
span += propertyTypes[i].getColumnSpan( mapping );
|
span += propertyTypes[i].getColumnSpan( mapping );
|
||||||
}
|
}
|
||||||
return span;
|
columnSpan = span;
|
||||||
}
|
}
|
||||||
|
return columnSpan;
|
||||||
|
}
|
||||||
|
|
||||||
|
private transient int[] sqlTypes;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
||||||
|
if ( sqlTypes == null ) {
|
||||||
//Not called at runtime so doesn't matter if its slow :)
|
//Not called at runtime so doesn't matter if its slow :)
|
||||||
int[] sqlTypes = new int[getColumnSpan( mapping )];
|
sqlTypes = new int[getColumnSpan( mapping )];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for ( int i = 0; i < propertySpan; i++ ) {
|
for ( int i = 0; i < propertySpan; i++ ) {
|
||||||
int[] subtypes = propertyTypes[i].sqlTypes( mapping );
|
int[] subtypes = propertyTypes[i].sqlTypes( mapping );
|
||||||
|
@ -121,6 +129,7 @@ public class ComponentType extends AbstractType implements CompositeType, Proced
|
||||||
sqlTypes[n++] = subtype;
|
sqlTypes[n++] = subtype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return sqlTypes;
|
return sqlTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +291,7 @@ public class ComponentType extends AbstractType implements CompositeType, Proced
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isDirty(Object x, Object y, boolean[] checkable, SessionImplementor session)
|
public boolean isDirty(Object x, Object y, boolean[] checkable, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
if ( x == y ) {
|
if ( x == y ) {
|
||||||
|
|
|
@ -36,15 +36,15 @@ public class EmbeddedComponentType extends ComponentType {
|
||||||
public EmbeddedComponentType(TypeFactory.TypeScope typeScope, ComponentMetamodel metamodel) {
|
public EmbeddedComponentType(TypeFactory.TypeScope typeScope, ComponentMetamodel metamodel) {
|
||||||
super( typeScope, metamodel );
|
super( typeScope, metamodel );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isEmbedded() {
|
public boolean isEmbedded() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isMethodOf(Method method) {
|
public boolean isMethodOf(Method method) {
|
||||||
return componentTuplizer.isMethodOf( method );
|
return componentTuplizer.isMethodOf( method );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object instantiate(Object parent, SessionImplementor session) throws HibernateException {
|
public Object instantiate(Object parent, SessionImplementor session) throws HibernateException {
|
||||||
final boolean useParent = parent!=null &&
|
final boolean useParent = parent!=null &&
|
||||||
//TODO: Yuck! This is not quite good enough, it's a quick
|
//TODO: Yuck! This is not quite good enough, it's a quick
|
||||||
|
|
|
@ -139,6 +139,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
*
|
*
|
||||||
* @return True.
|
* @return True.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isAssociationType() {
|
public boolean isAssociationType() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -148,13 +149,12 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
*
|
*
|
||||||
* @return True.
|
* @return True.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final boolean isEntityType() {
|
public final boolean isEntityType() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
*
|
*
|
||||||
* @return string rep
|
* @return string rep
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getName() + '(' + getAssociatedEntityName() + ')';
|
return getClass().getName() + '(' + getAssociatedEntityName() + ')';
|
||||||
}
|
}
|
||||||
|
@ -171,6 +172,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
/**
|
/**
|
||||||
* For entity types, the name correlates to the associated entity name.
|
* For entity types, the name correlates to the associated entity name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return associatedEntityName;
|
return associatedEntityName;
|
||||||
}
|
}
|
||||||
|
@ -184,13 +186,13 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
public boolean isReferenceToPrimaryKey() {
|
public boolean isReferenceToPrimaryKey() {
|
||||||
return referenceToPrimaryKey;
|
return referenceToPrimaryKey;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getRHSUniqueKeyPropertyName() {
|
public String getRHSUniqueKeyPropertyName() {
|
||||||
// Return null if this type references a PK. This is important for
|
// Return null if this type references a PK. This is important for
|
||||||
// associations' use of mappedBy referring to a derived ID.
|
// associations' use of mappedBy referring to a derived ID.
|
||||||
return referenceToPrimaryKey ? null : uniqueKeyPropertyName;
|
return referenceToPrimaryKey ? null : uniqueKeyPropertyName;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getLHSPropertyName() {
|
public String getLHSPropertyName() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -214,6 +216,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @param factory The session factory, for resolution.
|
* @param factory The session factory, for resolution.
|
||||||
* @return The associated entity name.
|
* @return The associated entity name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getAssociatedEntityName(SessionFactoryImplementor factory) {
|
public String getAssociatedEntityName(SessionFactoryImplementor factory) {
|
||||||
return getAssociatedEntityName();
|
return getAssociatedEntityName();
|
||||||
}
|
}
|
||||||
|
@ -225,6 +228,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @return The associated joinable
|
* @return The associated joinable
|
||||||
* @throws MappingException Generally indicates an invalid entity name.
|
* @throws MappingException Generally indicates an invalid entity name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) throws MappingException {
|
public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) throws MappingException {
|
||||||
return ( Joinable ) factory.getEntityPersister( associatedEntityName );
|
return ( Joinable ) factory.getEntityPersister( associatedEntityName );
|
||||||
}
|
}
|
||||||
|
@ -237,8 +241,9 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* entity persister (nor to the session factory, to look it up) which is really
|
* entity persister (nor to the session factory, to look it up) which is really
|
||||||
* needed to "do the right thing" here...
|
* needed to "do the right thing" here...
|
||||||
*
|
*
|
||||||
* @return The entiyt class.
|
* @return The entity class.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final Class getReturnedClass() {
|
public final Class getReturnedClass() {
|
||||||
if ( returnedClass == null ) {
|
if ( returnedClass == null ) {
|
||||||
returnedClass = determineAssociatedEntityClass();
|
returnedClass = determineAssociatedEntityClass();
|
||||||
|
@ -257,17 +262,13 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
return nullSafeGet( rs, new String[] {name}, session, owner );
|
return nullSafeGet( rs, new String[] {name}, session, owner );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public final Object nullSafeGet(
|
public final Object nullSafeGet(
|
||||||
ResultSet rs,
|
ResultSet rs,
|
||||||
String[] names,
|
String[] names,
|
||||||
|
@ -284,27 +285,22 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @param y Another entity instance
|
* @param y Another entity instance
|
||||||
* @return True if x == y; false otherwise.
|
* @return True if x == y; false otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final boolean isSame(Object x, Object y) {
|
public final boolean isSame(Object x, Object y) {
|
||||||
return x == y;
|
return x == y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public int compare(Object x, Object y) {
|
public int compare(Object x, Object y) {
|
||||||
return 0; //TODO: entities CAN be compared, by PK, fix this! -> only if/when we can extract the id values....
|
return 0; //TODO: entities CAN be compared, by PK, fix this! -> only if/when we can extract the id values....
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object deepCopy(Object value, SessionFactoryImplementor factory) {
|
public Object deepCopy(Object value, SessionFactoryImplementor factory) {
|
||||||
return value; //special case ... this is the leaf of the containment graph, even though not immutable
|
return value; //special case ... this is the leaf of the containment graph, even though not immutable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object replace(
|
public Object replace(
|
||||||
Object original,
|
Object original,
|
||||||
Object target,
|
Object target,
|
||||||
|
@ -342,9 +338,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public int getHashCode(Object x, SessionFactoryImplementor factory) {
|
public int getHashCode(Object x, SessionFactoryImplementor factory) {
|
||||||
EntityPersister persister = factory.getEntityPersister(associatedEntityName);
|
EntityPersister persister = factory.getEntityPersister(associatedEntityName);
|
||||||
if ( !persister.canExtractIdOutOfEntity() ) {
|
if ( !persister.canExtractIdOutOfEntity() ) {
|
||||||
|
@ -413,7 +407,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
return persister.getIdentifierType()
|
return persister.getIdentifierType()
|
||||||
.isEqual(xid, yid, factory);
|
.isEqual(xid, yid, factory);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
|
public String getOnCondition(String alias, SessionFactoryImplementor factory, Map<String, Filter> enabledFilters)
|
||||||
throws MappingException {
|
throws MappingException {
|
||||||
if ( isReferenceToPrimaryKey() ) { //TODO: this is a bit arbitrary, expose a switch to the user?
|
if ( isReferenceToPrimaryKey() ) { //TODO: this is a bit arbitrary, expose a switch to the user?
|
||||||
|
@ -427,6 +421,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
/**
|
/**
|
||||||
* Resolve an identifier or unique key value
|
* Resolve an identifier or unique key value
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -445,7 +440,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Type getSemiResolvedType(SessionFactoryImplementor factory) {
|
public Type getSemiResolvedType(SessionFactoryImplementor factory) {
|
||||||
return factory.getEntityPersister( associatedEntityName ).getIdentifierType();
|
return factory.getEntityPersister( associatedEntityName ).getIdentifierType();
|
||||||
}
|
}
|
||||||
|
@ -480,6 +475,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @return The loggable string.
|
* @return The loggable string.
|
||||||
* @throws HibernateException Generally some form of resolution problem.
|
* @throws HibernateException Generally some form of resolution problem.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toLoggableString(Object value, SessionFactoryImplementor factory) {
|
public String toLoggableString(Object value, SessionFactoryImplementor factory) {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return "null";
|
return "null";
|
||||||
|
@ -524,6 +520,9 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
return isOneToOne();
|
return isOneToOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private transient Type identifierType;
|
||||||
|
private transient Type identifierOrUniqueType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method to locate the identifier type of the associated entity.
|
* Convenience method to locate the identifier type of the associated entity.
|
||||||
*
|
*
|
||||||
|
@ -531,7 +530,10 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @return The identifier type
|
* @return The identifier type
|
||||||
*/
|
*/
|
||||||
Type getIdentifierType(Mapping factory) {
|
Type getIdentifierType(Mapping factory) {
|
||||||
return factory.getIdentifierType( getAssociatedEntityName() );
|
if ( identifierType == null ) {
|
||||||
|
identifierType = factory.getIdentifierType( getAssociatedEntityName() );
|
||||||
|
}
|
||||||
|
return identifierType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -555,18 +557,21 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* or unique key property name.
|
* or unique key property name.
|
||||||
*/
|
*/
|
||||||
public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingException {
|
public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingException {
|
||||||
|
if ( identifierOrUniqueType == null ) {
|
||||||
if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
|
if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
|
||||||
return getIdentifierType(factory);
|
identifierOrUniqueType = getIdentifierType( factory );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
||||||
if ( type.isEntityType() ) {
|
if ( type.isEntityType() ) {
|
||||||
type = ( ( EntityType ) type).getIdentifierOrUniqueKeyType( factory );
|
type = ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory );
|
||||||
}
|
}
|
||||||
return type;
|
identifierOrUniqueType = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return identifierOrUniqueType;
|
||||||
|
}
|
||||||
|
private transient String identifierOrUniquePropertyName;
|
||||||
/**
|
/**
|
||||||
* The name of the property on the associated entity to which our FK
|
* The name of the property on the associated entity to which our FK
|
||||||
* refers
|
* refers
|
||||||
|
@ -575,15 +580,17 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @return The appropriate property name.
|
* @return The appropriate property name.
|
||||||
* @throws MappingException Generally, if unable to resolve the associated entity name
|
* @throws MappingException Generally, if unable to resolve the associated entity name
|
||||||
*/
|
*/
|
||||||
public final String getIdentifierOrUniqueKeyPropertyName(Mapping factory)
|
public final String getIdentifierOrUniqueKeyPropertyName(Mapping factory) throws MappingException {
|
||||||
throws MappingException {
|
if ( identifierOrUniquePropertyName == null ) {
|
||||||
if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
|
if ( isReferenceToPrimaryKey() || uniqueKeyPropertyName == null ) {
|
||||||
return factory.getIdentifierPropertyName( getAssociatedEntityName() );
|
identifierOrUniquePropertyName = factory.getIdentifierPropertyName( getAssociatedEntityName() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return uniqueKeyPropertyName;
|
identifierOrUniquePropertyName = uniqueKeyPropertyName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return identifierOrUniquePropertyName;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract boolean isNullable();
|
protected abstract boolean isNullable();
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
*/
|
*/
|
||||||
public class ManyToOneType extends EntityType {
|
public class ManyToOneType extends EntityType {
|
||||||
private final boolean ignoreNotFound;
|
private final boolean ignoreNotFound;
|
||||||
private boolean isLogicalOneToOne;
|
private final boolean isLogicalOneToOne;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a many-to-one association type with the given referenced entity.
|
* Creates a many-to-one association type with the given referenced entity.
|
||||||
|
@ -113,11 +113,11 @@ public class ManyToOneType extends EntityType {
|
||||||
this.ignoreNotFound = ignoreNotFound;
|
this.ignoreNotFound = ignoreNotFound;
|
||||||
this.isLogicalOneToOne = isLogicalOneToOne;
|
this.isLogicalOneToOne = isLogicalOneToOne;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected boolean isNullable() {
|
protected boolean isNullable() {
|
||||||
return ignoreNotFound;
|
return ignoreNotFound;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isAlwaysDirtyChecked() {
|
public boolean isAlwaysDirtyChecked() {
|
||||||
// always need to dirty-check, even when non-updateable;
|
// always need to dirty-check, even when non-updateable;
|
||||||
// this ensures that when the association is updated,
|
// this ensures that when the association is updated,
|
||||||
|
@ -125,20 +125,20 @@ public class ManyToOneType extends EntityType {
|
||||||
// in the cache
|
// in the cache
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isOneToOne() {
|
public boolean isOneToOne() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isLogicalOneToOne() {
|
public boolean isLogicalOneToOne() {
|
||||||
return isLogicalOneToOne;
|
return isLogicalOneToOne;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(Mapping mapping) throws MappingException {
|
||||||
// our column span is the number of columns in the PK
|
// our column span is the number of columns in the PK
|
||||||
return getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
return getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
||||||
return getIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping );
|
return getIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping );
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public class ManyToOneType extends EntityType {
|
||||||
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
||||||
return getIdentifierOrUniqueKeyType( mapping ).defaultSizes( mapping );
|
return getIdentifierOrUniqueKeyType( mapping ).defaultSizes( mapping );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void nullSafeSet(
|
public void nullSafeSet(
|
||||||
PreparedStatement st,
|
PreparedStatement st,
|
||||||
Object value,
|
Object value,
|
||||||
|
@ -162,7 +162,7 @@ public class ManyToOneType extends EntityType {
|
||||||
getIdentifierOrUniqueKeyType( session.getFactory() )
|
getIdentifierOrUniqueKeyType( session.getFactory() )
|
||||||
.nullSafeSet( st, getIdentifier( value, session ), index, settable, session );
|
.nullSafeSet( st, getIdentifier( value, session ), index, settable, session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void nullSafeSet(
|
public void nullSafeSet(
|
||||||
PreparedStatement st,
|
PreparedStatement st,
|
||||||
Object value,
|
Object value,
|
||||||
|
@ -171,11 +171,11 @@ public class ManyToOneType extends EntityType {
|
||||||
getIdentifierOrUniqueKeyType( session.getFactory() )
|
getIdentifierOrUniqueKeyType( session.getFactory() )
|
||||||
.nullSafeSet( st, getIdentifier( value, session ), index, session );
|
.nullSafeSet( st, getIdentifier( value, session ), index, session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public ForeignKeyDirection getForeignKeyDirection() {
|
public ForeignKeyDirection getForeignKeyDirection() {
|
||||||
return ForeignKeyDirection.FROM_PARENT;
|
return ForeignKeyDirection.FROM_PARENT;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object hydrate(
|
public Object hydrate(
|
||||||
ResultSet rs,
|
ResultSet rs,
|
||||||
String[] names,
|
String[] names,
|
||||||
|
@ -204,11 +204,11 @@ public class ManyToOneType extends EntityType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean useLHSPrimaryKey() {
|
public boolean useLHSPrimaryKey() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isModified(
|
public boolean isModified(
|
||||||
Object old,
|
Object old,
|
||||||
Object current,
|
Object current,
|
||||||
|
@ -225,7 +225,7 @@ public class ManyToOneType extends EntityType {
|
||||||
return getIdentifierOrUniqueKeyType( session.getFactory() )
|
return getIdentifierOrUniqueKeyType( session.getFactory() )
|
||||||
.isDirty( old, getIdentifier( current, session ), session );
|
.isDirty( old, getIdentifier( current, session ), session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Serializable disassemble(
|
public Serializable disassemble(
|
||||||
Object value,
|
Object value,
|
||||||
SessionImplementor session,
|
SessionImplementor session,
|
||||||
|
@ -251,7 +251,7 @@ public class ManyToOneType extends EntityType {
|
||||||
return getIdentifierType( session ).disassemble( id, session, owner );
|
return getIdentifierType( session ).disassemble( id, session, owner );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object assemble(
|
public Object assemble(
|
||||||
Serializable oid,
|
Serializable oid,
|
||||||
SessionImplementor session,
|
SessionImplementor session,
|
||||||
|
@ -274,11 +274,11 @@ public class ManyToOneType extends EntityType {
|
||||||
//the owner of the association is not the owner of the id
|
//the owner of the association is not the owner of the id
|
||||||
return ( Serializable ) getIdentifierType( session ).assemble( oid, session, null );
|
return ( Serializable ) getIdentifierType( session ).assemble( oid, session, null );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void beforeAssemble(Serializable oid, SessionImplementor session) {
|
public void beforeAssemble(Serializable oid, SessionImplementor session) {
|
||||||
scheduleBatchLoadIfNeeded( assembleId( oid, session ), session );
|
scheduleBatchLoadIfNeeded( assembleId( oid, session ), session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
||||||
boolean[] result = new boolean[ getColumnSpan( mapping ) ];
|
boolean[] result = new boolean[ getColumnSpan( mapping ) ];
|
||||||
if ( value != null ) {
|
if ( value != null ) {
|
||||||
|
@ -286,7 +286,7 @@ public class ManyToOneType extends EntityType {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isDirty(
|
public boolean isDirty(
|
||||||
Object old,
|
Object old,
|
||||||
Object current,
|
Object current,
|
||||||
|
@ -298,7 +298,7 @@ public class ManyToOneType extends EntityType {
|
||||||
Object newid = getIdentifier( current, session );
|
Object newid = getIdentifier( current, session );
|
||||||
return getIdentifierType( session ).isDirty( oldid, newid, session );
|
return getIdentifierType( session ).isDirty( oldid, newid, session );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isDirty(
|
public boolean isDirty(
|
||||||
Object old,
|
Object old,
|
||||||
Object current,
|
Object current,
|
||||||
|
|
|
@ -36,11 +36,11 @@ public class ObjectType extends AnyType implements BasicType {
|
||||||
public ObjectType() {
|
public ObjectType() {
|
||||||
super( StringType.INSTANCE, SerializableType.INSTANCE );
|
super( StringType.INSTANCE, SerializableType.INSTANCE );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "object";
|
return "object";
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public String[] getRegistrationKeys() {
|
public String[] getRegistrationKeys() {
|
||||||
return new String[] { getName(), Object.class.getName() };
|
return new String[] { getName(), Object.class.getName() };
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,11 +98,11 @@ public class OneToOneType extends EntityType {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getPropertyName() {
|
public String getPropertyName() {
|
||||||
return propertyName;
|
return propertyName;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isNull(Object owner, SessionImplementor session) {
|
public boolean isNull(Object owner, SessionImplementor session) {
|
||||||
if ( propertyName != null ) {
|
if ( propertyName != null ) {
|
||||||
final EntityPersister ownerPersister = session.getFactory().getEntityPersister( entityName );
|
final EntityPersister ownerPersister = session.getFactory().getEntityPersister( entityName );
|
||||||
|
@ -114,11 +114,11 @@ public class OneToOneType extends EntityType {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int getColumnSpan(Mapping session) throws MappingException {
|
public int getColumnSpan(Mapping session) throws MappingException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int[] sqlTypes(Mapping session) throws MappingException {
|
public int[] sqlTypes(Mapping session) throws MappingException {
|
||||||
return ArrayHelper.EMPTY_INT_ARRAY;
|
return ArrayHelper.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
|
@ -134,39 +134,39 @@ public class OneToOneType extends EntityType {
|
||||||
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
||||||
return SIZES;
|
return SIZES;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
||||||
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isOneToOne() {
|
public boolean isOneToOne() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isDirty(Object old, Object current, SessionImplementor session) {
|
public boolean isDirty(Object old, Object current, SessionImplementor session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) {
|
public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session) {
|
public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public ForeignKeyDirection getForeignKeyDirection() {
|
public ForeignKeyDirection getForeignKeyDirection() {
|
||||||
return foreignKeyType;
|
return foreignKeyType;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object hydrate(
|
public Object hydrate(
|
||||||
ResultSet rs,
|
ResultSet rs,
|
||||||
String[] names,
|
String[] names,
|
||||||
|
@ -176,20 +176,20 @@ public class OneToOneType extends EntityType {
|
||||||
|
|
||||||
return session.getContextEntityIdentifier(owner);
|
return session.getContextEntityIdentifier(owner);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected boolean isNullable() {
|
protected boolean isNullable() {
|
||||||
return foreignKeyType==ForeignKeyDirection.TO_PARENT;
|
return foreignKeyType==ForeignKeyDirection.TO_PARENT;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean useLHSPrimaryKey() {
|
public boolean useLHSPrimaryKey() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
|
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object assemble(Serializable oid, SessionImplementor session, Object owner)
|
public Object assemble(Serializable oid, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
//this should be a call to resolve(), not resolveIdentifier(),
|
//this should be a call to resolve(), not resolveIdentifier(),
|
||||||
|
@ -203,6 +203,7 @@ public class OneToOneType extends EntityType {
|
||||||
* assemble/disassemble is implemented and because a one-to-one
|
* assemble/disassemble is implemented and because a one-to-one
|
||||||
* association is never dirty
|
* association is never dirty
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isAlwaysDirtyChecked() {
|
public boolean isAlwaysDirtyChecked() {
|
||||||
//TODO: this is kinda inconsistent with CollectionType
|
//TODO: this is kinda inconsistent with CollectionType
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -107,11 +107,11 @@ public class SpecialOneToOneType extends OneToOneType {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(Mapping mapping) throws MappingException {
|
||||||
return super.getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
return super.getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
public int[] sqlTypes(Mapping mapping) throws MappingException {
|
||||||
return super.getIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping );
|
return super.getIdentifierOrUniqueKeyType( mapping ).sqlTypes( mapping );
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,11 @@ public class SpecialOneToOneType extends OneToOneType {
|
||||||
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
public Size[] defaultSizes(Mapping mapping) throws MappingException {
|
||||||
return super.getIdentifierOrUniqueKeyType( mapping ).defaultSizes( mapping );
|
return super.getIdentifierOrUniqueKeyType( mapping ).defaultSizes( mapping );
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean useLHSPrimaryKey() {
|
public boolean useLHSPrimaryKey() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
return super.getIdentifierOrUniqueKeyType( session.getFactory() )
|
return super.getIdentifierOrUniqueKeyType( session.getFactory() )
|
||||||
|
@ -137,7 +137,7 @@ public class SpecialOneToOneType extends OneToOneType {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: copy/paste from ManyToOneType
|
// TODO: copy/paste from ManyToOneType
|
||||||
|
@Override
|
||||||
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
|
public Serializable disassemble(Object value, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
if (value==null) {
|
if (value==null) {
|
||||||
|
@ -156,7 +156,7 @@ public class SpecialOneToOneType extends OneToOneType {
|
||||||
return getIdentifierType(session).disassemble(id, session, owner);
|
return getIdentifierType(session).disassemble(id, session, owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public Object assemble(Serializable oid, SessionImplementor session, Object owner)
|
public Object assemble(Serializable oid, SessionImplementor session, Object owner)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
//TODO: currently broken for unique-key references (does not detect
|
//TODO: currently broken for unique-key references (does not detect
|
||||||
|
|
|
@ -72,7 +72,7 @@ public final class TypeFactory implements Serializable {
|
||||||
}
|
}
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public SessionFactoryImplementor resolveFactory() {
|
public SessionFactoryImplementor resolveFactory() {
|
||||||
if ( factory == null ) {
|
if ( factory == null ) {
|
||||||
throw new HibernateException( "SessionFactory for type scoping not yet known" );
|
throw new HibernateException( "SessionFactory for type scoping not yet known" );
|
||||||
|
|
|
@ -74,15 +74,6 @@ public class JdbcTypeNameMapper {
|
||||||
*
|
*
|
||||||
* @return {@code true} to indicate the type code is a standard type code; {@code false} otherwise.
|
* @return {@code true} to indicate the type code is a standard type code; {@code false} otherwise.
|
||||||
*/
|
*/
|
||||||
public static boolean isStandardTypeCode(int typeCode) {
|
|
||||||
return isStandardTypeCode( Integer.valueOf( typeCode ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as call to {@link #isStandardTypeCode(int)}
|
|
||||||
*
|
|
||||||
* @see #isStandardTypeCode(int)
|
|
||||||
*/
|
|
||||||
public static boolean isStandardTypeCode(Integer typeCode) {
|
public static boolean isStandardTypeCode(Integer typeCode) {
|
||||||
return JDBC_TYPE_MAP.containsKey( typeCode );
|
return JDBC_TYPE_MAP.containsKey( typeCode );
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class JdbcTypeFamilyInformation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentHashMap<Integer,Family> typeCodeToFamilyMap = new ConcurrentHashMap<Integer, Family>();
|
private final ConcurrentHashMap<Integer,Family> typeCodeToFamilyMap = new ConcurrentHashMap<Integer, Family>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will return {@code null} if no match is found.
|
* Will return {@code null} if no match is found.
|
||||||
|
@ -68,6 +68,6 @@ public class JdbcTypeFamilyInformation {
|
||||||
* @return The family of datatypes the type code belongs to, or {@code null} if it belongs to no known families.
|
* @return The family of datatypes the type code belongs to, or {@code null} if it belongs to no known families.
|
||||||
*/
|
*/
|
||||||
public Family locateJdbcTypeFamilyByTypeCode(int typeCode) {
|
public Family locateJdbcTypeFamilyByTypeCode(int typeCode) {
|
||||||
return typeCodeToFamilyMap.get( Integer.valueOf( typeCode ) );
|
return typeCodeToFamilyMap.get( typeCode );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SqlTypeDescriptorRegistry {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger( SqlTypeDescriptorRegistry.class );
|
private static final Logger log = Logger.getLogger( SqlTypeDescriptorRegistry.class );
|
||||||
|
|
||||||
private ConcurrentHashMap<Integer,SqlTypeDescriptor> descriptorMap = new ConcurrentHashMap<Integer, SqlTypeDescriptor>();
|
private final ConcurrentHashMap<Integer,SqlTypeDescriptor> descriptorMap = new ConcurrentHashMap<Integer, SqlTypeDescriptor>();
|
||||||
|
|
||||||
public void addDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
public void addDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
||||||
descriptorMap.put( sqlTypeDescriptor.getSqlType(), sqlTypeDescriptor );
|
descriptorMap.put( sqlTypeDescriptor.getSqlType(), sqlTypeDescriptor );
|
||||||
|
@ -72,7 +72,7 @@ public class SqlTypeDescriptorRegistry {
|
||||||
if ( family != null ) {
|
if ( family != null ) {
|
||||||
for ( int potentialAlternateTypeCode : family.getTypeCodes() ) {
|
for ( int potentialAlternateTypeCode : family.getTypeCodes() ) {
|
||||||
if ( potentialAlternateTypeCode != jdbcTypeCode ) {
|
if ( potentialAlternateTypeCode != jdbcTypeCode ) {
|
||||||
final SqlTypeDescriptor potentialAlternateDescriptor = descriptorMap.get( Integer.valueOf( potentialAlternateTypeCode ) );
|
final SqlTypeDescriptor potentialAlternateDescriptor = descriptorMap.get( potentialAlternateTypeCode );
|
||||||
if ( potentialAlternateDescriptor != null ) {
|
if ( potentialAlternateDescriptor != null ) {
|
||||||
// todo : add a SqlTypeDescriptor.canBeAssignedFrom method...
|
// todo : add a SqlTypeDescriptor.canBeAssignedFrom method...
|
||||||
return potentialAlternateDescriptor;
|
return potentialAlternateDescriptor;
|
||||||
|
|
|
@ -66,7 +66,7 @@ import static org.junit.Assert.fail;
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
//@FailureExpectedWithNewMetamodel
|
@FailureExpectedWithNewMetamodel
|
||||||
public class OneToManyTest extends BaseCoreFunctionalTestCase {
|
public class OneToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testColumnDefinitionPropagation() throws Exception {
|
public void testColumnDefinitionPropagation() throws Exception {
|
||||||
|
|
|
@ -56,7 +56,11 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* see {@link SingularIdentifierAttributeSourceImpl} basically, the {@link Details} class doesn't have an 'id' attribute
|
||||||
|
* it is a virtual attribute, but we need some api to define this, maybe add a method to the {@link org.hibernate.metamodel.spi.source.AttributeSource}
|
||||||
|
* say "isSynthetic()"
|
||||||
|
*/
|
||||||
@FailureExpectedWithNewMetamodel
|
@FailureExpectedWithNewMetamodel
|
||||||
public class MasterDetailTest extends LegacyTestCase {
|
public class MasterDetailTest extends LegacyTestCase {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue