Hibernate ORM EmptyInterceptor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM EmptyInterceptor class.

This code example shows how to use the following methods:
 */ 
public class SpringInterceptor extends EmptyInterceptor {
	private final SessionFactory sessionFactory;
	private final ApplicationContext beanRegistry;
 
	public SpringInterceptor(ApplicationContext beanRegistry, SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
		this.beanRegistry = beanRegistry;
	} 
 
	@Override 
	public Object instantiate(String entityName, EntityMode entityMode, Serializable id) {
		if (!EntityMode.POJO.equals(entityMode)) {
			return null; 
		} 
 
		Class<?> c = getClassByName(entityName);
		Object instance = this.beanRegistry.getBean(c);
		sessionFactory.getClassMetadata(c).setIdentifier(instance, id, EntityMode.POJO);
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 * called last, if they make any changes other interceptors would never know about them. 
 * </pre> 
 *  
 * @since 1.10 
 */ 
public abstract class ImmutableEntityInterceptor extends EmptyInterceptor {
	 
	private static final Log log = LogFactory.getLog(ImmutableEntityInterceptor.class);
	 
	/** 
	 * Returns the class handled by the interceptor 
	 */ 
	protected abstract Class<?> getSupportedType();
	 
	/** 
	 * Subclasses can override this to return fields that are allowed to be edited, returning null 
	 * or an empty array implies the entity is immutable 
	 *  
	 * @return an array of properties 
	 */ 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
 * recurse on lists of OpenmrsObjects. 
 * 
 * @since 1.9 
 */ 
 
public class AuditableInterceptor extends EmptyInterceptor {
	 
	private static final Log log = LogFactory.getLog(AuditableInterceptor.class);
	 
	private static final long serialVersionUID = 1L;
	 
	/** 
	 * This method is only called when inserting new objects. 
	 * @should return true if dateCreated was null 
	 * @should return true if creator was null 
	 * @should return false if dateCreated and creator was not null 
	 * @should be called when saving OpenmrsObject 
	 * @return true if the object got the dateCreated and creator fields set 
	 * @see org.hibernate.EmptyInterceptor#onSave(java.lang.Object, java.io.Serializable, 
	 *      java.lang.Object[], java.lang.String[], org.hibernate.type.Type[]) 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    private AuditLog auditLog;
    private InterceptHelper interceptHelper;
    private UserContext userContext;
    private Boolean flag = false;
 
    public AuditInterceptor() { 
        interceptHelper = new InterceptHelper();
    } 
 
    public void createInitialValueMap(Object object) { 
        userContext = ((AbstractBusinessObject) object).getUserContext();
        interceptHelper.hibernateMeta(object, AuditConstants.TRANSACTIONBEGIN);
    } 
 
    public void createChangeValueMap(Object object) { 
        if (interceptHelper.getEntityName().equals(AuditConfiguration.getEntityToClassPath(object.getClass().getName()))) {
            interceptHelper.hibernateMeta(object, AuditConstants.TRANSACTIONEND);
        } 
    } 
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
//$Id: CollectionInterceptor.java 7700 2005-07-30 05:02:47Z oneovthafew $ 
package org.hibernate.test.interceptor; 
import java.io.Serializable; 
import org.hibernate.EmptyInterceptor; 
import org.hibernate.type.Type; 
 
public class CollectionInterceptor extends EmptyInterceptor { 
 
	public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) { 
		( (User) entity ).getActions().add("updated"); 
		return false; 
	} 
 
	public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { 
		( (User) entity ).getActions().add("created"); 
		return false; 
	} 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Hibernate ORM EmptyInterceptor Methods: