|
Hibernate example source code file (ExceptionInterceptor.java)
The Hibernate ExceptionInterceptor.java source code//$Id$ package org.hibernate.ejb.test.ejb3configuration; import java.io.Serializable; import org.hibernate.CallbackException; import org.hibernate.EmptyInterceptor; import org.hibernate.type.Type; /** * @author Emmanuel Bernard */ public class ExceptionInterceptor extends EmptyInterceptor { public static final String EXCEPTION_MESSAGE = "Interceptor enabled"; protected boolean allowSave = false; public ExceptionInterceptor() { this.allowSave = false; } public ExceptionInterceptor(boolean allowSave) { this.allowSave = allowSave; } public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException { throw new IllegalStateException( EXCEPTION_MESSAGE ); } public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException { if (allowSave) return false; throw new IllegalStateException( EXCEPTION_MESSAGE ); } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate ExceptionInterceptor.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.