【JPA NonflushableQueryRapper公司】眼前多少难甘事,自古男儿当自强。这篇文章主要讲述JPA NonflushableQueryRapper公司相关的知识,希望能为你提供帮助。
Wrapper over JPA query that avoid flush
- import java.util.Calendar;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import javax.persistence.FlushModeType;
- import javax.persistence.LockModeType;
- import javax.persistence.Parameter;
- import javax.persistence.Query;
- import javax.persistence.TemporalType;
- /**
- * Wrapper sobre una query que evita que se haga flush en la consulta,
- * cambiando el modo del flush
- * @see Query
- * @author jose
- */
- public class NonFlushableQueryWrapper implements Query {
- private Query wrappedQuery;
- public NonFlushableQueryWrapper( Query query) {
- wrappedQuery = query;
- }
- @SuppressWarnings( " rawtypes" )
- @Override
- public List getResultList( ) {
- FlushModeType currentFlushMode = wrappedQuery.getFlushMode( ) ;
- try {
- wrappedQuery.setFlushMode( FlushModeType.COMMIT) ;
- return wrappedQuery.getResultList( ) ;
- } finally {
- wrappedQuery.setFlushMode( currentFlushMode) ;
- }
- }
- @Override
- public Object getSingleResult( ) {
- FlushModeType currentFlushMode = wrappedQuery.getFlushMode( ) ;
- try {
- wrappedQuery.setFlushMode( FlushModeType.COMMIT) ;
- return wrappedQuery.getSingleResult( ) ;
- } finally {
- wrappedQuery.setFlushMode( currentFlushMode) ;
- }
- }
- @Override
- public int executeUpdate( ) {
- return wrappedQuery.executeUpdate( ) ;
- }
- @Override
- public Query setMaxResults( int maxResult) {
- return wrappedQuery.setMaxResults( maxResult) ;
- }
- @Override
- public int getMaxResults( ) {
- return wrappedQuery.getMaxResults( ) ;
- }
- @Override
- public Query setFirstResult( int startPosition) {
- return wrappedQuery.setFirstResult( startPosition) ;
- }
- @Override
- public int getFirstResult( ) {
- return wrappedQuery.getFirstResult( ) ;
- }
- @Override
- public Query setHint( String hintName, Object value) {
- return wrappedQuery.setHint( hintName, value) ;
- }
- @Override
- public Map< String, Object> getHints( ) {
- return wrappedQuery.getHints( ) ;
- }
- @Override
- public < T> Query setParameter( Parameter< T> param, T value) {
- return wrappedQuery.setParameter( param, value) ;
- }
- @Override
- public Query setParameter( Parameter< Calendar> param, Calendar value, TemporalType temporalType) {
- return wrappedQuery.setParameter( param, value, temporalType) ;
- }
- @Override
- public Query setParameter( Parameter< Date> param, Date value, TemporalType temporalType) {
- return wrappedQuery.setParameter( param, value, temporalType) ;
- }
- @Override
- public Query setParameter( String name, Object value) {
- return wrappedQuery.setParameter( name, value) ;
- }
- @Override
- public Query setParameter( String name, Calendar value, TemporalType temporalType) {
- return wrappedQuery.setParameter( name, value, temporalType) ;
- }
- @Override
- public Query setParameter( String name, Date value, TemporalType temporalType) {
- return wrappedQuery.setParameter( name, value, temporalType) ;
- }
- @Override
- public Query setParameter( int position, Object value) {
- return wrappedQuery.setParameter( position, value) ;
- }
- @Override
- public Query setParameter( int position, Calendar value, TemporalType temporalType) {
- return wrappedQuery.setParameter( position, value, temporalType) ;
- }
- @Override
- public Query setParameter( int position, Date value, TemporalType temporalType) {
- return wrappedQuery.setParameter( position, value, temporalType) ;
- }
- @Override
- public Set< Parameter< ?> > getParameters( ) {
- return wrappedQuery.getParameters( ) ;
- }
- @Override
- public Parameter< ?> getParameter( String name) {
- return wrappedQuery.getParameter( name) ;
- }
- @Override
- public < T> Parameter< T> getParameter( String name, Class< T> type) {
- return wrappedQuery.getParameter( name, type) ;
- }
- @Override
- public Parameter< ?> getParameter( int position) {
- return wrappedQuery.getParameter( position) ;
- }
- @Override
- public < T> Parameter< T> getParameter( int position, Class< T> type) {
- return wrappedQuery.getParameter( position, type) ;
- }
- @Override
- public boolean isBound( Parameter< ?> param) {
- return wrappedQuery.isBound( param) ;
- }
- @Override
- public < T> T getParameterValue( Parameter< T> param) {
- return wrappedQuery.getParameterValue( param) ;
- }
- @Override
- public Object getParameterValue( String name) {
- return wrappedQuery.getParameterValue( name) ;
- }
- @Override
- public Object getParameterValue( int position) {
- return wrappedQuery.getParameterValue( position) ;
- }
- @Override
- public Query setFlushMode( FlushModeType flushMode) {
- return wrappedQuery.setFlushMode( flushMode) ;
- }
- @Override
- public FlushModeType getFlushMode( ) {
- return wrappedQuery.getFlushMode( ) ;
- }
- @Override
- public Query setLockMode( LockModeType lockMode) {
- return wrappedQuery.setLockMode( lockMode) ;
- }
- @Override
- public LockModeType getLockMode( ) {
- return wrappedQuery.getLockMode( ) ;
- }
- @Override
- public < T> T unwrap( Class< T> cls) {
- return wrappedQuery.unwrap( cls) ;
- }
- }
推荐阅读
- AppStore从网站自动检测应用程序
- Android(将文本绘制为动态大小的位图)
- 在Android应用程序中加载现有电子邮件并修改其内容
- 加载应用程序后刷新UIAppearance
- HTML中的Favicon和Apple图标
- 深入研究React Native(初学者教程)
- HTTP Live Streaming简介(Android上的HLS等)
- Haxe(跨平台开发的最佳秘密)
- 如何使用Angular 6 SPA进行JWT身份验证