Code example for EmptyInterceptor

0
import org.hibernate.EntityMode;
 
public class InstantiateInterceptor extends EmptyInterceptor {
	private String injectedString;
 
	public InstantiateInterceptor(String injectedString) {
		this.injectedString = injectedString;		
	} 
 
	public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException {
		if ( ! "org.hibernate.test.interceptor.User".equals( entityName ) ) {
			return null; 
		} 
		// Simply inject a sample string into new instances 
		User instance = new User();
		instance.setName( ( String ) id );
		instance.setInjectedString( injectedString );
		return instance;
	} 
} 
Connect your IDE to all the code out there  Get Codota for Java