Java Code Examples for org.hibernate.FlushMode#ALWAYS
The following examples show how to use
org.hibernate.FlushMode#ALWAYS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryBinder.java From lams with GNU General Public License v2.0 | 6 votes |
private static FlushMode getFlushMode(FlushModeType flushModeType) { FlushMode flushMode; switch ( flushModeType ) { case ALWAYS: flushMode = FlushMode.ALWAYS; break; case AUTO: flushMode = FlushMode.AUTO; break; case COMMIT: flushMode = FlushMode.COMMIT; break; case NEVER: flushMode = FlushMode.MANUAL; break; case MANUAL: flushMode = FlushMode.MANUAL; break; case PERSISTENCE_CONTEXT: flushMode = null; break; default: throw new AssertionFailure( "Unknown flushModeType: " + flushModeType ); } return flushMode; }
Example 2
Source File: NativeQueryImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private boolean shouldFlush() { if ( getProducer().isTransactionInProgress() ) { FlushMode effectiveFlushMode = getHibernateFlushMode(); if ( effectiveFlushMode == null ) { effectiveFlushMode = getProducer().getHibernateFlushMode(); } if ( effectiveFlushMode == FlushMode.ALWAYS ) { return true; } if ( effectiveFlushMode == FlushMode.AUTO ) { if ( getProducer().getFactory().getSessionFactoryOptions().isJpaBootstrap() ) { return true; } } } return false; }
Example 3
Source File: FlushModeTypeHelper.java From lams with GNU General Public License v2.0 | 6 votes |
public static FlushModeType getFlushModeType(FlushMode flushMode) { if ( flushMode == FlushMode.ALWAYS ) { log.debug( "Interpreting Hibernate FlushMode#ALWAYS to JPA FlushModeType#AUTO; may cause problems if relying on FlushMode#ALWAYS-specific behavior" ); return FlushModeType.AUTO; } else if ( flushMode == FlushMode.MANUAL ) { log.debug( "Interpreting Hibernate FlushMode#MANUAL to JPA FlushModeType#COMMIT; may cause problems if relying on FlushMode#MANUAL-specific behavior" ); return FlushModeType.COMMIT; } else if ( flushMode == FlushMode.COMMIT ) { return FlushModeType.COMMIT; } else if ( flushMode == FlushMode.AUTO ) { return FlushModeType.AUTO; } throw new AssertionFailure( "unhandled FlushMode " + flushMode ); }
Example 4
Source File: FlushModeConverter.java From lams with GNU General Public License v2.0 | 6 votes |
public static FlushMode fromXml(String name) { // valid values are a subset of all FlushMode possibilities, so we will // handle the conversion here directly. // Also, we want to map "never"->MANUAL (rather than NEVER) if ( name == null ) { return null; } if ( "never".equalsIgnoreCase( name ) ) { return FlushMode.MANUAL; } else if ( "auto".equalsIgnoreCase( name ) ) { return FlushMode.AUTO; } else if ( "always".equalsIgnoreCase( name ) ) { return FlushMode.ALWAYS; } // if the incoming value was not null *and* was not one of the pre-defined // values, we need to throw an exception. This *should never happen if the // document we are processing conforms to the schema... throw new HibernateException( "Unrecognized flush mode : " + name ); }
Example 5
Source File: HbmBinder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public static final FlushMode getFlushMode(String flushMode) { if ( flushMode == null ) { return null; } else if ( "auto".equals( flushMode ) ) { return FlushMode.AUTO; } else if ( "commit".equals( flushMode ) ) { return FlushMode.COMMIT; } else if ( "never".equals( flushMode ) ) { return FlushMode.NEVER; } else if ( "manual".equals( flushMode ) ) { return FlushMode.MANUAL; } else if ( "always".equals( flushMode ) ) { return FlushMode.ALWAYS; } else { throw new MappingException( "unknown flushmode" ); } }
Example 6
Source File: MutinySessionImpl.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public FlushMode getFlushMode() { switch ( delegate.getHibernateFlushMode() ) { case MANUAL: return FlushMode.MANUAL; case COMMIT: return FlushMode.COMMIT; case AUTO: return FlushMode.AUTO; case ALWAYS: return FlushMode.ALWAYS; default: throw new IllegalStateException("impossible flush mode"); } }
Example 7
Source File: StageSessionImpl.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public FlushMode getFlushMode() { switch ( delegate.getHibernateFlushMode() ) { case MANUAL: return FlushMode.MANUAL; case COMMIT: return FlushMode.COMMIT; case AUTO: return FlushMode.AUTO; case ALWAYS: return FlushMode.ALWAYS; default: throw new IllegalStateException("impossible flush mode"); } }
Example 8
Source File: DefaultReactiveAutoFlushEventListener.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getHibernateFlushMode() == FlushMode.ALWAYS || reactiveActionQueue( source ).areTablesToBeUpdated( event.getQuerySpaces() ); }
Example 9
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public FlushMode getInitialSessionFlushMode() { return FlushMode.ALWAYS; }
Example 10
Source File: DefaultAutoFlushEventListener.java From lams with GNU General Public License v2.0 | 4 votes |
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getHibernateFlushMode() == FlushMode.ALWAYS || source.getActionQueue().areTablesToBeUpdated( event.getQuerySpaces() ); }
Example 11
Source File: DefaultAutoFlushEventListener.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
private boolean flushIsReallyNeeded(AutoFlushEvent event, final EventSource source) { return source.getActionQueue() .areTablesToBeUpdated( event.getQuerySpaces() ) || source.getFlushMode()==FlushMode.ALWAYS; }
Example 12
Source File: AuthResource.java From robe with GNU Lesser General Public License v3.0 | 4 votes |
/** * check username and password for authentication * <p> * Status Code: * UNAUTHORIZED no have authentication. * INTERNAL_SERVER_ERROR Blocked. * * @param request HttpServletRequest * @param credentials username and password (SHA256) * @return {@link Response} * @throws Exception for createToken */ @POST @UnitOfWork(flushMode = FlushMode.ALWAYS) @Path("login") @Timed public Response login(@Context HttpServletRequest request, Map<String, String> credentials) throws Exception { Optional<User> user = userDao.findByUsername(credentials.get("username")); if (!user.isPresent()) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); } else if (user.get().getPassword().equals(credentials.get("password"))) { if (!user.get().isActive()) return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("User blocked.").build(); Map<String, String> attributes = new HashMap<>(); attributes.put("userAgent", request.getHeader("User-Agent")); attributes.put("remoteAddr", request.getRemoteAddr()); BasicToken token = new BasicToken(user.get().getUserId(), user.get().getEmail(), DateTime.now(), attributes); token.setExpiration(token.getMaxAge()); credentials.remove("password"); credentials.put("domain", TokenBasedAuthResponseFilter.getTokenSentence(null)); user.get().setLastLoginTime(DateTime.now().toDate()); user.get().setFailCount(0); logAction(new ActionLog("LOGIN", null, user.get().toString(), true, request.getRemoteAddr())); return Response.ok().header("Set-Cookie", TokenBasedAuthResponseFilter.getTokenSentence(token)).entity(credentials).build(); } else { if (!user.get().isActive()) { logAction(new ActionLog("LOGIN", "Blocked", user.get().toString(), false, request.getRemoteAddr())); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("User blocked.").build(); } int failCount = user.get().getFailCount() + 1; user.get().setFailCount(failCount); boolean block = failCount >= Integer.valueOf((String) SystemParameterCache.get("USER_BLOCK_FAIL_LIMIT", "3")); if (block) user.get().setActive(false); userDao.update(user.get()); logAction(new ActionLog("LOGIN", "Wrong Password", user.get().toString(), false, request.getRemoteAddr())); return Response.status(Response.Status.UNAUTHORIZED).build(); } }