
com.yammer.dropwizard.hibernate.UnitOfWork Maven / Gradle / Ivy
package com.yammer.dropwizard.hibernate;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* When annotating a Jersey resource method, wraps the method in a Hibernate session.
*
* @see UnitOfWorkRequestDispatcher
*/
@Target(METHOD)
@Retention(RUNTIME)
@Documented
public @interface UnitOfWork {
/**
* If {@code true}, the Hibernate session will default to loading read-only entities.
*
* @see org.hibernate.Session#setDefaultReadOnly(boolean)
*/
boolean readOnly() default false;
/**
* If {@code true}, a transaction will be automatically started before the resource method is
* invoked, committed if the method returned, and rolled back if an exception was thrown.
*/
boolean transactional() default true;
/**
* The {@link CacheMode} for the session.
*
* @see CacheMode
* @see org.hibernate.Session#setCacheMode(CacheMode)
*/
CacheMode cacheMode() default CacheMode.NORMAL;
/**
* The {@link FlushMode} for the session.
*
* @see FlushMode
* @see org.hibernate.Session#setFlushMode(org.hibernate.FlushMode)
*/
FlushMode flushMode() default FlushMode.AUTO;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy