remove Serializable id from the Tuplizer stuff
This commit is contained in:
parent
d4aa643630
commit
b3aa7d0794
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.userguide.proxy.tuplizer;
|
package org.hibernate.userguide.proxy.tuplizer;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -30,7 +30,7 @@ public final class DataProxyHandler implements InvocationHandler {
|
||||||
|
|
||||||
private Map<String, Object> data = new HashMap<>();
|
private Map<String, Object> data = new HashMap<>();
|
||||||
|
|
||||||
public DataProxyHandler(String entityName, Serializable id) {
|
public DataProxyHandler(String entityName, Object id) {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
data.put( "Id", id );
|
data.put( "Id", id );
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class DynamicInstantiator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
return ProxyHelper.newProxy( targetClass, id );
|
return ProxyHelper.newProxy( targetClass, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.userguide.proxy.tuplizer;
|
package org.hibernate.userguide.proxy.tuplizer;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
public class ProxyHelper {
|
public class ProxyHelper {
|
||||||
|
|
||||||
public static <T> T newProxy(Class<T> targetClass, Serializable id) {
|
public static <T> T newProxy(Class<T> targetClass, Object id) {
|
||||||
return ( T ) Proxy.newProxyInstance(
|
return ( T ) Proxy.newProxyInstance(
|
||||||
targetClass.getClassLoader(),
|
targetClass.getClassLoader(),
|
||||||
new Class[] {
|
new Class[] {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.tuple;
|
package org.hibernate.tuple;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -37,7 +36,7 @@ public class DynamicMapInstantiator implements Instantiator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Object instantiate(Serializable id) {
|
public final Object instantiate(Object id) {
|
||||||
return instantiate();
|
return instantiate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public interface Instantiator extends Serializable {
|
||||||
* @param id The id of the entity to be instantiated.
|
* @param id The id of the entity to be instantiated.
|
||||||
* @return An appropriately instantiated entity.
|
* @return An appropriately instantiated entity.
|
||||||
*/
|
*/
|
||||||
Object instantiate(Serializable id);
|
Object instantiate(Object id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the requested instantiation.
|
* Perform the requested instantiation.
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class PojoInstantiator implements Instantiator, Serializable {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
final boolean useEmbeddedIdentifierInstanceAsEntity = embeddedIdentifier &&
|
final boolean useEmbeddedIdentifierInstanceAsEntity = embeddedIdentifier &&
|
||||||
id != null &&
|
id != null &&
|
||||||
id.getClass().equals(mappedClass);
|
id.getClass().equals(mappedClass);
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
throw new AssertionFailure( "ProxiedInstantiator can only be used to instantiate component" );
|
throw new AssertionFailure( "ProxiedInstantiator can only be used to instantiate component" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,12 +203,12 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getIdentifier(Object entity) throws HibernateException {
|
public Object getIdentifier(Object entity) throws HibernateException {
|
||||||
return getIdentifier( entity, null );
|
return getIdentifier( entity, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
||||||
final Object id;
|
final Object id;
|
||||||
if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
|
if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
|
||||||
id = entity;
|
id = entity;
|
||||||
|
@ -231,7 +231,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (Serializable) id;
|
return id;
|
||||||
}
|
}
|
||||||
catch (ClassCastException cce) {
|
catch (ClassCastException cce) {
|
||||||
StringBuilder msg = new StringBuilder( "Identifier classes must be serializable. " );
|
StringBuilder msg = new StringBuilder( "Identifier classes must be serializable. " );
|
||||||
|
@ -246,14 +246,14 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id) throws HibernateException {
|
public void setIdentifier(Object entity, Object id) throws HibernateException {
|
||||||
// 99% of the time the session is not needed. It's only needed for certain brain-dead
|
// 99% of the time the session is not needed. It's only needed for certain brain-dead
|
||||||
// interpretations of JPA 2 "derived identity" support
|
// interpretations of JPA 2 "derived identity" support
|
||||||
setIdentifier( entity, id, null );
|
setIdentifier( entity, id, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||||
if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
|
if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) {
|
||||||
if ( entity != id ) {
|
if ( entity != id ) {
|
||||||
CompositeType copier = (CompositeType) entityMetamodel.getIdentifierProperty().getType();
|
CompositeType copier = (CompositeType) entityMetamodel.getIdentifierProperty().getType();
|
||||||
|
@ -271,7 +271,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
private static interface MappedIdentifierValueMarshaller {
|
private static interface MappedIdentifierValueMarshaller {
|
||||||
public Object getIdentifier(Object entity, EntityMode entityMode, SharedSessionContractImplementor session);
|
public Object getIdentifier(Object entity, EntityMode entityMode, SharedSessionContractImplementor session);
|
||||||
|
|
||||||
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SharedSessionContractImplementor session);
|
public void setIdentifier(Object entity, Object id, EntityMode entityMode, SharedSessionContractImplementor session);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MappedIdentifierValueMarshaller mappedIdentifierValueMarshaller;
|
private final MappedIdentifierValueMarshaller mappedIdentifierValueMarshaller;
|
||||||
|
@ -334,7 +334,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, EntityMode entityMode, SharedSessionContractImplementor session) {
|
||||||
virtualIdComponent.setPropertyValues(
|
virtualIdComponent.setPropertyValues(
|
||||||
entity,
|
entity,
|
||||||
mappedIdentifierType.getPropertyValues( id, session ),
|
mappedIdentifierType.getPropertyValues( id, session ),
|
||||||
|
@ -398,7 +398,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, EntityMode entityMode, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, EntityMode entityMode, SharedSessionContractImplementor 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];
|
||||||
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
|
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
|
||||||
|
@ -503,7 +503,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetIdentifier(Object entity, Serializable currentId, Object currentVersion) {
|
public void resetIdentifier(Object entity, Object currentId, Object currentVersion) {
|
||||||
// 99% of the time the session is not needed. It's only needed for certain brain-dead
|
// 99% of the time the session is not needed. It's only needed for certain brain-dead
|
||||||
// interpretations of JPA 2 "derived identity" support
|
// interpretations of JPA 2 "derived identity" support
|
||||||
resetIdentifier( entity, currentId, currentVersion, null );
|
resetIdentifier( entity, currentId, currentVersion, null );
|
||||||
|
@ -524,7 +524,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
Object result = identifierProperty
|
Object result = identifierProperty
|
||||||
.getUnsavedValue()
|
.getUnsavedValue()
|
||||||
.getDefaultValue( currentId );
|
.getDefaultValue( currentId );
|
||||||
setIdentifier( entity, (Serializable) result, session );
|
setIdentifier( entity, result, session );
|
||||||
//reset the version
|
//reset the version
|
||||||
VersionProperty versionProperty = entityMetamodel.getVersionProperty();
|
VersionProperty versionProperty = entityMetamodel.getVersionProperty();
|
||||||
if ( entityMetamodel.isVersioned() ) {
|
if ( entityMetamodel.isVersioned() ) {
|
||||||
|
@ -693,14 +693,14 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Object instantiate(Serializable id) throws HibernateException {
|
public final Object instantiate(Object id) throws HibernateException {
|
||||||
// 99% of the time the session is not needed. It's only needed for certain brain-dead
|
// 99% of the time the session is not needed. It's only needed for certain brain-dead
|
||||||
// interpretations of JPA 2 "derived identity" support
|
// interpretations of JPA 2 "derived identity" support
|
||||||
return instantiate( id, null );
|
return instantiate( id, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Object instantiate(Serializable id, SharedSessionContractImplementor session) {
|
public final Object instantiate(Object id, SharedSessionContractImplementor session) {
|
||||||
Object result = getInstantiator().instantiate( id );
|
Object result = getInstantiator().instantiate( id );
|
||||||
linkToSession( result, session );
|
linkToSession( result, session );
|
||||||
if ( id != null ) {
|
if ( id != null ) {
|
||||||
|
@ -741,7 +741,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Object createProxy(Serializable id, SharedSessionContractImplementor session) {
|
public final Object createProxy(Object id, SharedSessionContractImplementor session) {
|
||||||
return getProxyFactory().getProxy( id, session );
|
return getProxyFactory().getProxy( id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.tuple.entity;
|
package org.hibernate.tuple.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.EntityMode;
|
import org.hibernate.EntityMode;
|
||||||
|
@ -47,11 +46,11 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
* @return The instantiated entity.
|
* @return The instantiated entity.
|
||||||
* @throws HibernateException
|
* @throws HibernateException
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link #instantiate(Serializable, SharedSessionContractImplementor)} instead.
|
* @deprecated Use {@link #instantiate(Object, SharedSessionContractImplementor)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings( {"JavaDoc"})
|
@SuppressWarnings( {"JavaDoc"})
|
||||||
Object instantiate(Serializable id) throws HibernateException;
|
Object instantiate(Object id) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an entity instance initialized with the given identifier.
|
* Create an entity instance initialized with the given identifier.
|
||||||
|
@ -61,7 +60,7 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
*
|
*
|
||||||
* @return The instantiated entity.
|
* @return The instantiated entity.
|
||||||
*/
|
*/
|
||||||
Object instantiate(Serializable id, SharedSessionContractImplementor session);
|
Object instantiate(Object id, SharedSessionContractImplementor session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the identifier value from the given entity.
|
* Extract the identifier value from the given entity.
|
||||||
|
@ -76,7 +75,7 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
* @deprecated Use {@link #getIdentifier(Object,SharedSessionContractImplementor)} instead.
|
* @deprecated Use {@link #getIdentifier(Object,SharedSessionContractImplementor)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
Serializable getIdentifier(Object entity) throws HibernateException;
|
Object getIdentifier(Object entity) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract the identifier value from the given entity.
|
* Extract the identifier value from the given entity.
|
||||||
|
@ -86,7 +85,7 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
*
|
*
|
||||||
* @return The identifier value.
|
* @return The identifier value.
|
||||||
*/
|
*/
|
||||||
Serializable getIdentifier(Object entity, SharedSessionContractImplementor session);
|
Object getIdentifier(Object entity, SharedSessionContractImplementor session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject the identifier value into the given entity.
|
* Inject the identifier value into the given entity.
|
||||||
|
@ -96,11 +95,11 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
* @param entity The entity to inject with the identifier value.
|
* @param entity The entity to inject with the identifier value.
|
||||||
* @param id The value to be injected as the identifier.
|
* @param id The value to be injected as the identifier.
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link #setIdentifier(Object, Serializable, SharedSessionContractImplementor)} instead.
|
* @deprecated Use {@link #setIdentifier(Object, Object, SharedSessionContractImplementor)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings( {"JavaDoc"})
|
@SuppressWarnings( {"JavaDoc"})
|
||||||
void setIdentifier(Object entity, Serializable id) throws HibernateException;
|
void setIdentifier(Object entity, Object id) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject the identifier value into the given entity.
|
* Inject the identifier value into the given entity.
|
||||||
|
@ -111,7 +110,7 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
* @param id The value to be injected as the identifier.
|
* @param id The value to be injected as the identifier.
|
||||||
* @param session The session from which is requests originates
|
* @param session The session from which is requests originates
|
||||||
*/
|
*/
|
||||||
void setIdentifier(Object entity, Serializable id, SharedSessionContractImplementor session);
|
void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject the given identifier and version into the entity, in order to
|
* Inject the given identifier and version into the entity, in order to
|
||||||
|
@ -125,7 +124,7 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings( {"UnusedDeclaration"})
|
@SuppressWarnings( {"UnusedDeclaration"})
|
||||||
void resetIdentifier(Object entity, Serializable currentId, Object currentVersion);
|
void resetIdentifier(Object entity, Object currentId, Object currentVersion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject the given identifier and version into the entity, in order to
|
* Inject the given identifier and version into the entity, in order to
|
||||||
|
@ -212,7 +211,7 @@ public interface EntityTuplizer extends Tuplizer {
|
||||||
* @return The generate proxies.
|
* @return The generate proxies.
|
||||||
* @throws HibernateException Indicates an error generating the proxy.
|
* @throws HibernateException Indicates an error generating the proxy.
|
||||||
*/
|
*/
|
||||||
Object createProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException;
|
Object createProxy(Object id, SharedSessionContractImplementor session) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the {@link #getMappedClass() class} managed by this tuplizer implement
|
* Does the {@link #getMappedClass() class} managed by this tuplizer implement
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class GetIdentifierTest {
|
||||||
ModernEntity modernEntity = new ModernEntity();
|
ModernEntity modernEntity = new ModernEntity();
|
||||||
modernEntity.setFoo( 2 );
|
modernEntity.setFoo( 2 );
|
||||||
|
|
||||||
Serializable simpleEntityId = (Serializable) entityManager.getEntityManagerFactory()
|
Object simpleEntityId = entityManager.getEntityManagerFactory()
|
||||||
.getPersistenceUnitUtil().getIdentifier( modernEntity );
|
.getPersistenceUnitUtil().getIdentifier( modernEntity );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.tuplizer;
|
package org.hibernate.test.annotations.tuplizer;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -25,7 +25,7 @@ public final class DataProxyHandler implements InvocationHandler {
|
||||||
private String entityName;
|
private String entityName;
|
||||||
private HashMap data = new HashMap();
|
private HashMap data = new HashMap();
|
||||||
|
|
||||||
public DataProxyHandler(String entityName, Serializable id) {
|
public DataProxyHandler(String entityName, Object id) {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
data.put( "Id", id );
|
data.put( "Id", id );
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.tuplizer;
|
package org.hibernate.test.annotations.tuplizer;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ public class DynamicInstantiator implements Instantiator {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
if ( Cuisine.class.getName().equals( entityName ) ) {
|
if ( Cuisine.class.getName().equals( entityName ) ) {
|
||||||
return ProxyHelper.newCuisineProxy( id );
|
return ProxyHelper.newCuisineProxy( id );
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.tuplizer;
|
package org.hibernate.test.annotations.tuplizer;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class ProxyHelper {
|
||||||
return newCountryProxy( null );
|
return newCountryProxy( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Country newCountryProxy(Serializable id) {
|
public static Country newCountryProxy(Object id) {
|
||||||
return ( Country ) Proxy.newProxyInstance(
|
return ( Country ) Proxy.newProxyInstance(
|
||||||
Country.class.getClassLoader(),
|
Country.class.getClassLoader(),
|
||||||
new Class[] {Country.class},
|
new Class[] {Country.class},
|
||||||
|
@ -32,7 +32,7 @@ public class ProxyHelper {
|
||||||
return newCuisineProxy( null );
|
return newCuisineProxy( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cuisine newCuisineProxy(Serializable id) {
|
public static Cuisine newCuisineProxy(Object id) {
|
||||||
return ( Cuisine ) Proxy.newProxyInstance(
|
return ( Cuisine ) Proxy.newProxyInstance(
|
||||||
Cuisine.class.getClassLoader(),
|
Cuisine.class.getClassLoader(),
|
||||||
new Class[] {Cuisine.class},
|
new Class[] {Cuisine.class},
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.tuplizer.bytebuddysubclass;
|
package org.hibernate.test.annotations.tuplizer.bytebuddysubclass;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.tuple.Instantiator;
|
import org.hibernate.tuple.Instantiator;
|
||||||
|
|
||||||
|
@ -28,7 +26,7 @@ public class MyEntityInstantiator implements Instantiator {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
return instantiate();
|
return instantiate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.bytecode.enhancement.lazy.proxy;
|
package org.hibernate.test.bytecode.enhancement.lazy.proxy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
|
@ -304,38 +303,38 @@ public class LazyToOnesNoProxyFactoryWithSubclassesStatefulTest extends BaseNonC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiate(Serializable id) throws HibernateException {
|
public Object instantiate(Object id) throws HibernateException {
|
||||||
return pojoEntityTuplizer.instantiate( id );
|
return pojoEntityTuplizer.instantiate( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiate(Serializable id, SharedSessionContractImplementor session) {
|
public Object instantiate(Object id, SharedSessionContractImplementor session) {
|
||||||
return pojoEntityTuplizer.instantiate( id, session );
|
return pojoEntityTuplizer.instantiate( id, session );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getIdentifier(Object entity) throws HibernateException {
|
public Object getIdentifier(Object entity) throws HibernateException {
|
||||||
return pojoEntityTuplizer.getIdentifier( entity );
|
return pojoEntityTuplizer.getIdentifier( entity );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
||||||
return pojoEntityTuplizer.getIdentifier( entity, session );
|
return pojoEntityTuplizer.getIdentifier( entity, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id) throws HibernateException {
|
public void setIdentifier(Object entity, Object id) throws HibernateException {
|
||||||
pojoEntityTuplizer.setIdentifier( entity, id );
|
pojoEntityTuplizer.setIdentifier( entity, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||||
pojoEntityTuplizer.setIdentifier( entity, id, session );
|
pojoEntityTuplizer.setIdentifier( entity, id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetIdentifier(Object entity, Serializable currentId, Object currentVersion) {
|
public void resetIdentifier(Object entity, Object currentId, Object currentVersion) {
|
||||||
pojoEntityTuplizer.resetIdentifier( entity, currentId, currentVersion );
|
pojoEntityTuplizer.resetIdentifier( entity, currentId, currentVersion );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +387,7 @@ public class LazyToOnesNoProxyFactoryWithSubclassesStatefulTest extends BaseNonC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException {
|
public Object createProxy(Object id, SharedSessionContractImplementor session) throws HibernateException {
|
||||||
return pojoEntityTuplizer.createProxy( id, session );
|
return pojoEntityTuplizer.createProxy( id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.bytecode.enhancement.lazy.proxy;
|
package org.hibernate.test.bytecode.enhancement.lazy.proxy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
|
@ -305,38 +304,38 @@ public class LazyToOnesNoProxyFactoryWithSubclassesStatelessTest extends BaseNon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiate(Serializable id) throws HibernateException {
|
public Object instantiate(Object id) throws HibernateException {
|
||||||
return pojoEntityTuplizer.instantiate( id );
|
return pojoEntityTuplizer.instantiate( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiate(Serializable id, SharedSessionContractImplementor session) {
|
public Object instantiate(Object id, SharedSessionContractImplementor session) {
|
||||||
return pojoEntityTuplizer.instantiate( id, session );
|
return pojoEntityTuplizer.instantiate( id, session );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getIdentifier(Object entity) throws HibernateException {
|
public Object getIdentifier(Object entity) throws HibernateException {
|
||||||
return pojoEntityTuplizer.getIdentifier( entity );
|
return pojoEntityTuplizer.getIdentifier( entity );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Serializable getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
public Object getIdentifier(Object entity, SharedSessionContractImplementor session) {
|
||||||
return pojoEntityTuplizer.getIdentifier( entity, session );
|
return pojoEntityTuplizer.getIdentifier( entity, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id) throws HibernateException {
|
public void setIdentifier(Object entity, Object id) throws HibernateException {
|
||||||
pojoEntityTuplizer.setIdentifier( entity, id );
|
pojoEntityTuplizer.setIdentifier( entity, id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setIdentifier(Object entity, Serializable id, SharedSessionContractImplementor session) {
|
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
|
||||||
pojoEntityTuplizer.setIdentifier( entity, id, session );
|
pojoEntityTuplizer.setIdentifier( entity, id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resetIdentifier(Object entity, Serializable currentId, Object currentVersion) {
|
public void resetIdentifier(Object entity, Object currentId, Object currentVersion) {
|
||||||
pojoEntityTuplizer.resetIdentifier( entity, currentId, currentVersion );
|
pojoEntityTuplizer.resetIdentifier( entity, currentId, currentVersion );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +388,7 @@ public class LazyToOnesNoProxyFactoryWithSubclassesStatelessTest extends BaseNon
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException {
|
public Object createProxy(Object id, SharedSessionContractImplementor session) throws HibernateException {
|
||||||
return pojoEntityTuplizer.createProxy( id, session );
|
return pojoEntityTuplizer.createProxy( id, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.dynamicentity;
|
package org.hibernate.test.dynamicentity;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -23,7 +23,7 @@ public final class DataProxyHandler implements InvocationHandler {
|
||||||
private String entityName;
|
private String entityName;
|
||||||
private HashMap data = new HashMap();
|
private HashMap data = new HashMap();
|
||||||
|
|
||||||
public DataProxyHandler(String entityName, Serializable id) {
|
public DataProxyHandler(String entityName, Object id) {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
data.put( "Id", id );
|
data.put( "Id", id );
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.dynamicentity;
|
package org.hibernate.test.dynamicentity;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class ProxyHelper {
|
||||||
return newPersonProxy( null );
|
return newPersonProxy( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Person newPersonProxy(Serializable id) {
|
public static Person newPersonProxy(Object id) {
|
||||||
return ( Person ) Proxy.newProxyInstance(
|
return ( Person ) Proxy.newProxyInstance(
|
||||||
Person.class.getClassLoader(),
|
Person.class.getClassLoader(),
|
||||||
new Class[] {Person.class},
|
new Class[] {Person.class},
|
||||||
|
@ -30,7 +30,7 @@ public class ProxyHelper {
|
||||||
return newCustomerProxy( null );
|
return newCustomerProxy( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Customer newCustomerProxy(Serializable id) {
|
public static Customer newCustomerProxy(Object id) {
|
||||||
return ( Customer ) Proxy.newProxyInstance(
|
return ( Customer ) Proxy.newProxyInstance(
|
||||||
Customer.class.getClassLoader(),
|
Customer.class.getClassLoader(),
|
||||||
new Class[] {Customer.class},
|
new Class[] {Customer.class},
|
||||||
|
@ -42,7 +42,7 @@ public class ProxyHelper {
|
||||||
return newCompanyProxy( null );
|
return newCompanyProxy( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Company newCompanyProxy(Serializable id) {
|
public static Company newCompanyProxy(Object id) {
|
||||||
return ( Company ) Proxy.newProxyInstance(
|
return ( Company ) Proxy.newProxyInstance(
|
||||||
Company.class.getClassLoader(),
|
Company.class.getClassLoader(),
|
||||||
new Class[] {Company.class},
|
new Class[] {Company.class},
|
||||||
|
@ -54,7 +54,7 @@ public class ProxyHelper {
|
||||||
return newAddressProxy( null );
|
return newAddressProxy( null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Address newAddressProxy(Serializable id) {
|
public static Address newAddressProxy(Object id) {
|
||||||
return ( Address ) Proxy.newProxyInstance(
|
return ( Address ) Proxy.newProxyInstance(
|
||||||
Address.class.getClassLoader(),
|
Address.class.getClassLoader(),
|
||||||
new Class[] {Address.class},
|
new Class[] {Address.class},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.dynamicentity.tuplizer;
|
package org.hibernate.test.dynamicentity.tuplizer;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
|
|
||||||
|
@ -31,7 +30,7 @@ public class MyEntityInstantiator implements Instantiator {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
if ( Person.class.getName().equals( entityName ) ) {
|
if ( Person.class.getName().equals( entityName ) ) {
|
||||||
return ProxyHelper.newPersonProxy( id );
|
return ProxyHelper.newPersonProxy( id );
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.dynamicentity.tuplizer2;
|
package org.hibernate.test.dynamicentity.tuplizer2;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.test.dynamicentity.Address;
|
import org.hibernate.test.dynamicentity.Address;
|
||||||
|
@ -27,7 +25,7 @@ public class MyEntityInstantiator implements Instantiator {
|
||||||
this.entityName = entityName;
|
this.entityName = entityName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object instantiate(Serializable id) {
|
public Object instantiate(Object id) {
|
||||||
if ( Person.class.getName().equals( entityName ) ) {
|
if ( Person.class.getName().equals( entityName ) ) {
|
||||||
return ProxyHelper.newPersonProxy( id );
|
return ProxyHelper.newPersonProxy( id );
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public final class ToOneEntityLoader {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Not audited relation, look up entity with Hibernate.
|
// Not audited relation, look up entity with Hibernate.
|
||||||
return versionsReader.getSessionImplementor().immediateLoad( entityName, (Serializable) entityId );
|
return versionsReader.getSessionImplementor().immediateLoad( entityName, entityId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public final class ToOneEntityLoader {
|
||||||
.getMetamodel()
|
.getMetamodel()
|
||||||
.entityPersister( entityName );
|
.entityPersister( entityName );
|
||||||
return persister.createProxy(
|
return persister.createProxy(
|
||||||
(Serializable) entityId,
|
entityId,
|
||||||
new ToOneDelegateSessionImplementor( versionsReader, entityClass, entityId, revision, removed, enversService )
|
new ToOneDelegateSessionImplementor( versionsReader, entityClass, entityId, revision, removed, enversService )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue