All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.intercept.javassist.JavassistHelper Maven / Gradle / Ivy

There is a newer version: 3.6.0.Beta2
Show newest version
package org.hibernate.intercept.javassist;

import org.hibernate.intercept.FieldInterceptor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.bytecode.javassist.FieldHandled;

import java.util.Set;

/**
 * @author Steve Ebersole
 */
public class JavassistHelper {
	private JavassistHelper() {
	}

	public static FieldInterceptor extractFieldInterceptor(Object entity) {
		return ( FieldInterceptor ) ( ( FieldHandled ) entity ).getFieldHandler();
	}

	public static FieldInterceptor injectFieldInterceptor(
			Object entity,
	        String entityName,
	        Set uninitializedFieldNames,
	        SessionImplementor session) {
		FieldInterceptorImpl fieldInterceptor = new FieldInterceptorImpl( session, uninitializedFieldNames, entityName );
		( ( FieldHandled ) entity ).setFieldHandler( fieldInterceptor );
		return fieldInterceptor;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy