Java Code Examples for org.hibernate.FlushMode#MANUAL
The following examples show how to use
org.hibernate.FlushMode#MANUAL .
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: JobResource.java From robe with GNU Lesser General Public License v3.0 | 6 votes |
/** * Returns all HTriggerInfo as a collection with the matches given job id. * * @param credentials auto fill by {@link RobeAuth} annotation for authentication. * @return all {@link HTriggerInfo} as a collection */ @RobeService(group = "HJobInfo", description = "Returns all HTriggerInfo as a collection with the matches given job id.") @PUT @Path("{id}/pause") @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public boolean pause(@RobeAuth Credentials credentials, @PathParam("id") String id) { HJobInfo info = jobDao.findById(id); if (info == null) { throw new WebApplicationException(Response.status(404).build()); } try { JobManager.getInstance().pauseJob(info.getName(), info.getGroup()); } catch (SchedulerException e) { e.printStackTrace(); return false; } return true; }
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: TriggerResource.java From robe with GNU Lesser General Public License v3.0 | 6 votes |
@RobeService(group = "HJobInfo", description = "Returns all HTriggerInfo as a collection with the matches given job id.") @PUT @Path("{id}/schedule") @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public boolean schedule(@RobeAuth Credentials credentials, @PathParam("id") String id) { HTriggerInfo info = triggerDao.findById(id); HJobInfo jobEntity = jobDao.findById(info.getJobOid()); if (info == null || jobEntity == null) { throw new WebApplicationException(Response.status(404).build()); } JobInfo job = new HibernateJobInfoProvider().getJob(jobEntity.getJobClass()); try { if (info.getType().equals(TriggerInfo.Type.CRON) || info.getType().equals(TriggerInfo.Type.SIMPLE)) { Trigger trigger = new HibernateJobInfoProvider().convert2Trigger(info, job); JobManager.getInstance().scheduleTrigger(trigger); return true; } } catch (SchedulerException e) { e.printStackTrace(); } return false; }
Example 5
Source File: JobResource.java From robe with GNU Lesser General Public License v3.0 | 6 votes |
/** * Return all HJobInfo as a collection * * @param credentials auto fill by {@link RobeAuth} annotation for authentication. * @return all {@link HJobInfo} as a collection */ @RobeService(group = "HJobInfo", description = "Returns all HJobInfo as a collection.") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public Collection<JobInfoDTO> getAll(@RobeAuth Credentials credentials, @SearchParam SearchModel search) { List<JobInfoDTO> dtoList = new LinkedList<>(); for (HJobInfo info : jobDao.findAllStrict(search)) { JobInfoDTO dto = new JobInfoDTO(info); try { if (!JobManager.getInstance().isScheduledJob(dto.getName(), dto.getGroup())) { dto.setStatus(JobInfoDTO.Status.UNSCHEDULED); } else { if (JobManager.getInstance().isPausedJob(dto.getName(), dto.getGroup())) { dto.setStatus(JobInfoDTO.Status.PAUSED); } else { dto.setStatus(JobInfoDTO.Status.ACTIVE); } } } catch (SchedulerException e) { e.printStackTrace(); } dtoList.add(dto); } return dtoList; }
Example 6
Source File: SessionFactoryImpl.java From lams with GNU General Public License v2.0 | 6 votes |
SessionBuilderImpl(SessionFactoryImpl sessionFactory) { this.sessionFactory = sessionFactory; this.sessionOwner = null; // set up default builder values... this.statementInspector = sessionFactory.getSessionFactoryOptions().getStatementInspector(); this.connectionHandlingMode = sessionFactory.getSessionFactoryOptions().getPhysicalConnectionHandlingMode(); this.autoClose = sessionFactory.getSessionFactoryOptions().isAutoCloseSessionEnabled(); this.flushMode = sessionFactory.getSessionFactoryOptions().isFlushBeforeCompletionEnabled() ? FlushMode.AUTO : FlushMode.MANUAL; if ( sessionFactory.getCurrentTenantIdentifierResolver() != null ) { tenantIdentifier = sessionFactory.getCurrentTenantIdentifierResolver().resolveCurrentTenantIdentifier(); } this.jdbcTimeZone = sessionFactory.getSessionFactoryOptions().getJdbcTimeZone(); listeners = sessionFactory.getSessionFactoryOptions().getBaselineSessionEventsListenerBuilder().buildBaselineList(); queryParametersValidationEnabled = sessionFactory.getSessionFactoryOptions().isQueryParametersValidationEnabled(); }
Example 7
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 8
Source File: MenuResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * get menu for logged user * * @param credentials injected by {@link RobeAuth} annotation for authentication. * @return user {@link MenuItem} as collection */ @RobeService(group = "Menu", description = "Get menu for logged user") @Path("user") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) @CacheControl(noCache = true) public List<MenuItem> getUserHierarchicalMenu(@RobeAuth Credentials credentials) { Optional<User> user = userDao.findByUsername(credentials.getUsername()); Set<Permission> permissions = new HashSet<Permission>(); Role parent = roleDao.findById(user.get().getRoleOid()); getAllRolePermissions(parent, permissions); Set<String> menuOids = new HashSet<String>(); List<MenuItem> items = convertMenuToMenuItem(menuDao.findHierarchicalMenu()); items = readMenuHierarchical(items); for (Permission permission : permissions) { if (permission.getType().equals(Permission.Type.MENU)) { menuOids.add(permission.getRestrictedItemOid()); } } List<MenuItem> permittedItems = new LinkedList<MenuItem>(); createMenuWithPermissions(menuOids, items, permittedItems); return permittedItems; }
Example 9
Source File: RoleResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Return all Role as a collection * * @param credentials auto fill by {@link RobeAuth} annotation for authentication. * @return all {@link Role} as a collection */ @RobeService(group = "Role", description = "Returns all Role as a collection.") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public List<Role> getAll(@RobeAuth Credentials credentials, @SearchParam SearchModel search) { return roleDao.findAllStrict(search); }
Example 10
Source File: AuthResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * User Information Returns * <p> * Status Code: * UNAUTHORIZED no have authentication. * * @param credentials injected by {@link RobeAuth} annotation for authentication. * @return {@link User} * @throws Exception for not found user */ @Path("profile") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public User getProfile(@RobeAuth Credentials credentials) { Optional<User> user = userDao.findByUsername(credentials.getUsername()); if (!user.isPresent()) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); } else return user.get(); }
Example 11
Source File: SystemParameterResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Return {@link SystemParameter) resource and matches with the given id. * * @param credentials Injected by {@link RobeAuth} annotation for authentication. * @param id This is the oid of {@link SystemParameter} * @return {@link SystemParameter} resource matches with the given id. */ @RobeService(group = "SystemParameter", description = "Return SystemParameter resource.") @Path("{id}") @GET @UnitOfWork(readOnly = true, cacheMode = CacheMode.GET, flushMode = FlushMode.MANUAL) public SystemParameter get(@RobeAuth Credentials credentials, @PathParam("id") String id) { SystemParameter entity = systemParameterDao.findById(id); if (entity == null) { throw new WebApplicationException(Response.status(404).build()); } return entity; }
Example 12
Source File: UserResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns all {@link User}s as a collection. * * @param credentials injected by {@link RobeAuth} annotation for authentication. * @return all {@link User}s as a collection with. */ @RobeService(group = "User", description = "Returns all Users as a collection.") @GET @UnitOfWork(readOnly = true, cacheMode = CacheMode.GET, flushMode = FlushMode.MANUAL) public List<User> getAll(@RobeAuth Credentials credentials, @SearchParam SearchModel search) { return userDao.findAllStrict(search); }
Example 13
Source File: MenuResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns all {@link Menu}s as a collection. * * @param credentials injected by {@link RobeAuth} annotation for authentication. * @return all {@link Menu}s as a collection with. */ @RobeService(group = "Menu", description = "Returns all Menu's as a collection.") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public List<Menu> getAll(@RobeAuth Credentials credentials, @SearchParam SearchModel search) { return menuDao.findAllStrict(search); }
Example 14
Source File: GrailsOpenSessionInViewInterceptor.java From gorm-hibernate5 with Apache License 2.0 | 5 votes |
public void setHibernateDatastore(AbstractHibernateDatastore hibernateDatastore) { String defaultFlushModeName = hibernateDatastore.getDefaultFlushModeName(); if(hibernateDatastore.isOsivReadOnly()) { this.hibernateFlushMode = FlushMode.MANUAL; } else { this.hibernateFlushMode = FlushMode.valueOf(defaultFlushModeName); } setSessionFactory(hibernateDatastore.getSessionFactory()); }
Example 15
Source File: MenuResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns a single Menu matches with the given id. * <p> * Status Code: * Not Found 404 * * @param credentials injected by {@link RobeAuth} annotation for authentication. * @param id This is the oid of {@link Menu} * @return a {@link Menu} resource matches with the given id. */ @RobeService(group = "Menu", description = "Returns a Menu resource matches with the given id.") @Path("{id}") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public Menu get(@RobeAuth Credentials credentials, @PathParam("id") String id) { Menu entity = menuDao.findById(id); if (entity == null) { throw new WebApplicationException(Response.status(404).build()); } return entity; }
Example 16
Source File: FlushModeConverter.java From lams with GNU General Public License v2.0 | 5 votes |
public static String toXml(FlushMode mode) { if ( mode == null ) { return null; } // conversely, we want to map MANUAL -> "never" here if ( mode == FlushMode.MANUAL ) { return "never"; } // todo : what to do if the incoming value does not conform to allowed values? // for now, we simply don't deal with that (we write it out). return mode.name().toLowerCase( Locale.ENGLISH ); }
Example 17
Source File: SessionImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public boolean shouldDoManagedFlush(SessionImplementor session) { if ( session.isClosed() ) { return false; } return session.getHibernateFlushMode() != FlushMode.MANUAL; }
Example 18
Source File: RoleResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Return a Role resource with the matches given id. * <p> * Status Code: * Not Found 404 * * @param credentials auto fill by @{@link RobeAuth} annotation for authentication. * @param id This is the oid of {@link Role} * @return a {@link Role} resource with the matches given id. */ @RobeService(group = "Role", description = "Returns a Role resource with the matches given id.") @Path("{id}") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public Role get(@RobeAuth Credentials credentials, @PathParam("id") String id) { Role entity = roleDao.findById(id); if (entity == null) { throw new WebApplicationException(Response.status(404).build()); } return entity; }
Example 19
Source File: PermissionResource.java From robe with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns a {@link Permission} resource with the given id * <p> * Status Code: * Not Found 404 * * @param credentials Injected by @{@link RobeAuth} annotation for authentication. * @param id This is the oid of {@link Permission} * @return a @{@link Permission} resource macthes with the given id. */ @RobeService(group = "Permission", description = "Returns a permission resource with the given id") @Path("{id}") @GET @UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL) public Permission get(@RobeAuth Credentials credentials, @PathParam("id") String id) { Permission entity = permissionDao.findById(id); if (entity == null) { throw new WebApplicationException(Response.status(404).build()); } return entity; }
Example 20
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"); } }