Java Code Examples for org.hibernate.internal.util.ReflectHelper#overridesEquals()
The following examples show how to use
org.hibernate.internal.util.ReflectHelper#overridesEquals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RootClass.java From lams with GNU General Public License v2.0 | 6 votes |
private void checkCompositeIdentifier() { if ( getIdentifier() instanceof Component ) { Component id = (Component) getIdentifier(); if ( !id.isDynamic() ) { final Class idClass = id.getComponentClass(); if ( idClass != null ) { final String idComponentClassName = idClass.getName(); if ( !ReflectHelper.overridesEquals( idClass ) ) { LOG.compositeIdClassDoesNotOverrideEquals( idComponentClassName ); } if ( !ReflectHelper.overridesHashCode( idClass ) ) { LOG.compositeIdClassDoesNotOverrideHashCode( idComponentClassName ); } if ( !Serializable.class.isAssignableFrom( idClass ) ) { throw new MappingException( "Composite-id class must implement Serializable: " + idComponentClassName ); } } } } }
Example 2
Source File: JavassistProxyFactory.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void postInstantiate( final String entityName, final Class persistentClass, final Set<Class> interfaces, final Method getIdentifierMethod, final Method setIdentifierMethod, CompositeType componentIdType) throws HibernateException { this.entityName = entityName; this.persistentClass = persistentClass; this.interfaces = toArray( interfaces ); this.getIdentifierMethod = getIdentifierMethod; this.setIdentifierMethod = setIdentifierMethod; this.componentIdType = componentIdType; this.overridesEquals = ReflectHelper.overridesEquals( persistentClass ); this.proxyClass = buildJavassistProxyFactory().createClass(); }
Example 3
Source File: ByteBuddyProxyFactory.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void postInstantiate( String entityName, Class persistentClass, Set<Class> interfaces, Method getIdentifierMethod, Method setIdentifierMethod, CompositeType componentIdType) throws HibernateException { this.entityName = entityName; this.persistentClass = persistentClass; this.interfaces = toArray( interfaces ); this.getIdentifierMethod = getIdentifierMethod; this.setIdentifierMethod = setIdentifierMethod; this.componentIdType = componentIdType; this.overridesEquals = ReflectHelper.overridesEquals( persistentClass ); this.proxyClass = byteBuddyProxyHelper.buildProxy( persistentClass, this.interfaces ); }
Example 4
Source File: ProxyDefinitions.java From quarkus with Apache License 2.0 | 5 votes |
public static ProxyDefinitions createFromMetadata(Metadata storeableMetadata, PreGeneratedProxies preGeneratedProxies) { //Check upfront for any need across all metadata: would be nice to avoid initializing the Bytecode provider. LazyBytecode lazyBytecode = new LazyBytecode(); if (needAnyProxyDefinitions(storeableMetadata)) { final HashMap<Class<?>, ProxyClassDetailsHolder> proxyDefinitionMap = new HashMap<>(); try { for (PersistentClass persistentClass : storeableMetadata.getEntityBindings()) { if (needsProxyGeneration(persistentClass)) { final Class mappedClass = persistentClass.getMappedClass(); final Class proxyClassDefinition = generateProxyClass(persistentClass, lazyBytecode, preGeneratedProxies); if (proxyClassDefinition == null) { continue; } final boolean overridesEquals = ReflectHelper.overridesEquals(mappedClass); try { proxyDefinitionMap.put(mappedClass, new ProxyClassDetailsHolder(overridesEquals, proxyClassDefinition.getConstructor())); } catch (NoSuchMethodException e) { throw new HibernateException( "Failed to generate Enhanced Proxy: default constructor is missing for entity '" + mappedClass.getName() + "'. Please add a default constructor explicitly."); } } } } finally { lazyBytecode.close(); } return new ProxyDefinitions(proxyDefinitionMap); } else { return new ProxyDefinitions(Collections.emptyMap()); } }
Example 5
Source File: ByteBuddyProxyHelper.java From lams with GNU General Public License v2.0 | 5 votes |
public HibernateProxy deserializeProxy(SerializableProxy serializableProxy) { final ByteBuddyInterceptor interceptor = new ByteBuddyInterceptor( serializableProxy.getEntityName(), serializableProxy.getPersistentClass(), serializableProxy.getInterfaces(), serializableProxy.getId(), resolveIdGetterMethod( serializableProxy ), resolveIdSetterMethod( serializableProxy ), serializableProxy.getComponentIdType(), null, ReflectHelper.overridesEquals( serializableProxy.getPersistentClass() ) ); // note: interface is assumed to already contain HibernateProxy.class try { final Class proxyClass = buildProxy( serializableProxy.getPersistentClass(), serializableProxy.getInterfaces() ); final HibernateProxy proxy = (HibernateProxy) proxyClass.newInstance(); ( (ProxyConfiguration) proxy ).$$_hibernate_set_interceptor( interceptor ); return proxy; } catch (Throwable t) { final String message = LOG.bytecodeEnhancementFailed( serializableProxy.getEntityName() ); LOG.error( message, t ); throw new HibernateException( message, t ); } }
Example 6
Source File: JavaTypeDescriptorRegistry.java From lams with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("unchecked") private void checkEqualsAndHashCode(Class javaType) { if ( !ReflectHelper.overridesEquals( javaType ) || !ReflectHelper.overridesHashCode( javaType ) ) { log.unknownJavaTypeNoEqualsHashCode( javaType ); } }