List of usage examples for org.springframework.dao InvalidDataAccessResourceUsageException InvalidDataAccessResourceUsageException
public InvalidDataAccessResourceUsageException(String msg)
From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpQuery.java
/** * Executes a cqp command.//w w w. ja va 2s.co m * * @param aCmd * command you want to send to cqp * @return output of cqp triggered by the command */ private List<String> exec(String aCmd) throws DataAccessException { String line; List<String> output = new ArrayList<String>(); try { // the .EOL. is essential for checking whether we are finished reading send(aCmd + ";.EOL."); TimeoutReader reader = new TimeoutReader( new InputStreamReader(cqpProcess.getInputStream(), engine.getEncoding(corpus))); reader.setTimeout(timeout); while ((line = reader.readLine()) != null) { if (line.equals(CQP_EOL)) { if (log.isTraceEnabled()) { log.trace(CQP_EOL); } break; } if (log.isTraceEnabled()) { log.trace("<< " + line); } output.add(line); } } catch (IOException e) { throw new InvalidDataAccessResourceUsageException(e.getMessage()); } checkError(); return output; }
From source file:com.turbospaces.spaces.AbstractJSpace.java
private void write0(final TransactionModificationContext modificationContext, final Object entry, final byte[] serializedEntry, final int timeToLive, final int timeout, final int modifier) { Preconditions.checkNotNull(entry);//from w w w . j a v a 2s. co m Preconditions.checkArgument(timeToLive >= 0, NEGATIVE_TTL); Preconditions.checkArgument(timeout >= 0, NEGATIVE_TIMEOUT); Class<?> persistentClass = entry.getClass(); SpaceStore heapBuffer = offHeapBuffers.get(persistentClass); BO bo = configuration.boFor(entry.getClass()); boolean isWriteOnly = SpaceModifiers.isWriteOnly(modifier); boolean isWriteOrUpdate = SpaceModifiers.isWriteOrUpdate(modifier); boolean isUpdateOnly = SpaceModifiers.isUpdateOnly(modifier); CacheStoreEntryWrapper cacheStoreEntryWrapper = CacheStoreEntryWrapper.writeValueOf(bo, entry); Preconditions.checkNotNull(cacheStoreEntryWrapper.getId(), "ID must be provided before writing to JSpace"); cacheStoreEntryWrapper.setBeanAsBytes(serializedEntry); if (isWriteOnly && isUpdateOnly) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to write %s with writeOnly and updateOnly modifiers at the same time", entry)); if (isWriteOrUpdate && isUpdateOnly) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to write %s with writeOrUpdate and updateOnly modifiers at the same time", entry)); if (isWriteOrUpdate && isWriteOnly) throw new InvalidDataAccessResourceUsageException(String.format( "Illegal attempt to write %s with writeOrUpdate and writeOnly modifiers at the same time", entry)); if (logger.isDebugEnabled()) logger.debug("onWrite: entity {}, id={}, version={}, routing={} under {} transaction. ttl = {}", new Object[] { entry, cacheStoreEntryWrapper.getId(), cacheStoreEntryWrapper.getOptimisticLockVersion(), cacheStoreEntryWrapper.getRouting(), modificationContext.getTransactionId(), timeToLive }); // write heapBuffer.write(cacheStoreEntryWrapper, modificationContext, timeToLive, timeout, modifier); }
From source file:org.grails.datastore.mapping.core.AbstractSession.java
public void flush() { if (exceptionOccurred) { throw new InvalidDataAccessResourceUsageException( "Do not flush() the Session after an exception occurs"); }/*from w ww . ja va 2 s .c om*/ boolean hasInserts = hasUpdates(); if (!hasInserts) { return; } flushPendingInserts(pendingInserts); pendingInserts.clear(); flushPendingUpdates(pendingUpdates); pendingUpdates.clear(); executePendings(pendingDeletes); handleDirtyCollections(); firstLevelCollectionCache.clear(); executePendings(postFlushOperations); postFlush(hasInserts); }
From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpQuery.java
/** * Checks the stderr for errors thrown by cqp. *///www . jav a 2 s.c o m private void checkError() throws InvalidDataAccessResourceUsageException { String line; try { BufferedReader _br = new BufferedReader( new InputStreamReader(cqpProcess.getErrorStream(), engine.getEncoding(corpus))); while (_br.ready()) { line = _br.readLine(); if (log.isErrorEnabled()) { log.error(line); } error.add(line); } } catch (IOException e) { throw new InvalidDataAccessResourceUsageException(e.getMessage()); } if (!error.isEmpty()) { throw new InvalidDataAccessResourceUsageException(join(error, "\n")); } }
From source file:com.algoTrader.entity.security.SecurityFamilyDaoBase.java
/** * {@inheritDoc}// ww w . ja v a2 s . c o m */ @Override @SuppressWarnings("unchecked") public Object findByIsin(final int transform, final String queryString, final String isin) { try { Query queryObject = super.getSession(false).createQuery(queryString); queryObject.setCacheable(true); queryObject.setParameter("isin", isin); Set results = new LinkedHashSet(queryObject.list()); Object result = null; if (results.size() > 1) { throw new InvalidDataAccessResourceUsageException( "More than one instance of 'com.algoTrader.entity.security.SecurityFamily" + "' was found when executing query --> '" + queryString + "'"); } else if (results.size() == 1) { result = results.iterator().next(); } if (transform != TRANSFORM_NONE) { result = transformEntity(transform, (SecurityFamily) result); } return result; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.WatchListItemDaoBase.java
/** * {@inheritDoc}/*from w w w .j av a 2s .co m*/ */ @Override @SuppressWarnings("unchecked") public Object findByStrategyAndSecurity(final int transform, final String queryString, final String strategyName, final int securityId) { try { Query queryObject = super.getSession(false).createQuery(queryString); queryObject.setCacheable(true); queryObject.setParameter("strategyName", strategyName); queryObject.setParameter("securityId", new Integer(securityId)); Set results = new LinkedHashSet(queryObject.list()); Object result = null; if (results.size() > 1) { throw new InvalidDataAccessResourceUsageException( "More than one instance of 'com.algoTrader.entity.WatchListItem" + "' was found when executing query --> '" + queryString + "'"); } else if (results.size() == 1) { result = results.iterator().next(); } if (transform != TRANSFORM_NONE) { result = transformEntity(transform, (WatchListItem) result); } return result; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.StrategyDaoBase.java
/** * {@inheritDoc}/* w w w.j a v a 2 s. c o m*/ */ @Override @SuppressWarnings("unchecked") public Object findByName(final int transform, final String queryString, final String name) { try { Query queryObject = super.getSession(false).createQuery(queryString); queryObject.setCacheable(true); queryObject.setParameter("name", name); Set results = new LinkedHashSet(queryObject.list()); Object result = null; if (results.size() > 1) { throw new InvalidDataAccessResourceUsageException( "More than one instance of 'com.algoTrader.entity.Strategy" + "' was found when executing query --> '" + queryString + "'"); } else if (results.size() == 1) { result = results.iterator().next(); } if (transform != TRANSFORM_NONE) { result = transformEntity(transform, (Strategy) result); } return result; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.security.SecurityDaoBase.java
/** * {@inheritDoc}/*w w w . j ava 2 s . com*/ */ @Override @SuppressWarnings("unchecked") public Object findByIsinFetched(final int transform, final String queryString, final String isin) { try { Query queryObject = super.getSession(false).createQuery(queryString); queryObject.setCacheable(true); queryObject.setParameter("isin", isin); Set results = new LinkedHashSet(queryObject.list()); Object result = null; if (results.size() > 1) { throw new InvalidDataAccessResourceUsageException( "More than one instance of 'com.algoTrader.entity.security.Security" + "' was found when executing query --> '" + queryString + "'"); } else if (results.size() == 1) { result = results.iterator().next(); } if (transform != TRANSFORM_NONE) { result = transformEntity(transform, (Security) result); } return result; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.marketData.TickDaoBase.java
/** * {@inheritDoc}//from w w w. j a v a 2 s.co m */ @Override @SuppressWarnings("unchecked") public Object findLastTickForSecurityAndMaxDate(final int transform, final String queryString, final int securityId, final Date maxDate) { try { SQLQuery queryObject = super.getSession(false).createSQLQuery(queryString); queryObject.addEntity(TickImpl.class); queryObject.setParameter("securityId", new Integer(securityId)); queryObject.setParameter("maxDate", maxDate); Set results = new LinkedHashSet(queryObject.list()); Object result = null; if (results.size() > 1) { throw new InvalidDataAccessResourceUsageException( "More than one instance of 'com.algoTrader.entity.marketData.Tick" + "' was found when executing query --> '" + queryString + "'"); } else if (results.size() == 1) { result = results.iterator().next(); } if (transform != TRANSFORM_NONE) { result = transformEntity(transform, (Tick) result); } return result; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:org.grails.datastore.mapping.gemfire.query.GemfireQuery.java
private static void validateProperty(PersistentEntity entity, String name, Class criterionType) { if (entity.getIdentity().getName().equals(name)) return;//from w w w.java 2 s .c om PersistentProperty prop = entity.getPropertyByName(name); if (prop == null) { throw new InvalidDataAccessResourceUsageException("Cannot use [" + criterionType.getSimpleName() + "] criterion on non-existent property: " + name); } }