List of usage examples for org.springframework.dao InvalidDataAccessResourceUsageException InvalidDataAccessResourceUsageException
public InvalidDataAccessResourceUsageException(String msg)
From source file:org.grails.datastore.mapping.engine.types.AbstractMappingAwareCustomTypeMarshaller.java
@SuppressWarnings("unused") protected void queryInternal(PersistentProperty property, String key, Query.PropertyCriterion value, Q nativeQuery) {// w w w . ja va2s.c o m throw new InvalidDataAccessResourceUsageException( "Custom type [" + getTargetType().getName() + "] does not support querying"); }
From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpQuery.java
/** * Constructs a CQPManager./*ww w. java 2 s. c o m*/ */ public CqpQuery(CqpEngine aEngine, String aType, String aCorpus) { engine = aEngine; type = aType; corpus = aCorpus; if (corpus == null) { throw new InvalidDataAccessResourceUsageException("Corpus cannot be null."); } error = new ArrayList<String>(); cqpProcess = getCQPProcess(); // -- set obligatory options -- // corpus List<String> output = exec(corpus); if (output.size() > 0) { version = StringUtils.substringAfter(output.get(0), CQP_VERSION_PREFIX); } // add macro definitions if (engine.getMacrosLocation() != null) { setMacrosLocation(engine.getMacrosLocation()); } // set default delimiters (can be changed) setLeftDelim(leftDelim); setRightDelim(rightDelim); // show positional attributes send("show +" + ATTR_BEGIN); send("show +" + ATTR_END); send("set PrintStructures \"" + E_TEXT + "_" + ATTR_ID + "\""); // activate progressbar (essential, because we stop reading at EOL, which occurs after // the progress messages send("set ProgressBar on"); }
From source file:org.mybatis.spring.batch.MyBatisBatchItemWriter.java
/** * {@inheritDoc}//from w w w . j a v a 2s . c o m */ @Override public void write(final List<? extends T> items) { if (!items.isEmpty()) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Executing batch with " + items.size() + " items."); } for (T item : items) { sqlSessionTemplate.update(statementId, item); } List<BatchResult> results = sqlSessionTemplate.flushStatements(); if (assertUpdates) { if (results.size() != 1) { throw new InvalidDataAccessResourceUsageException("Batch execution returned invalid results. " + "Expected 1 but number of BatchResult objects returned was " + results.size()); } int[] updateCounts = results.get(0).getUpdateCounts(); for (int i = 0; i < updateCounts.length; i++) { int value = updateCounts[i]; if (value == 0) { throw new EmptyResultDataAccessException("Item " + i + " of " + updateCounts.length + " did not update any rows: [" + items.get(i) + "]", 1); } } } } }
From source file:org.grails.datastore.mapping.query.jpa.JpaQueryBuilder.java
/** * Builds an UPDATE statement./*ww w . ja v a2 s.c o m*/ * * @param propertiesToUpdate THe properties to update * @return The JpaQueryInfo object */ public JpaQueryInfo buildUpdate(Map<String, Object> propertiesToUpdate) { if (propertiesToUpdate.isEmpty()) { throw new InvalidDataAccessResourceUsageException("No properties specified to update"); } StringBuilder queryString = new StringBuilder(UPDATE_CLAUSE).append(entity.getName()).append(SPACE) .append(logicalName); List parameters = new ArrayList(); buildUpdateStatement(queryString, propertiesToUpdate, parameters, hibernateCompatible); StringBuilder whereClause = new StringBuilder(); buildWhereClause(entity, criteria, queryString, whereClause, logicalName, false, parameters); return new JpaQueryInfo(queryString.toString(), parameters); }
From source file:de.tudarmstadt.ukp.csniper.webapp.search.cqp.CqpQuery.java
/** * Sends a size command to cqp./* ww w. j a v a 2 s .co m*/ * * @return size of the last query sent to cqp via runQuery() */ @Override public int size() throws DataAccessException { if (!querySuccess) { log.warn("A query has to be run via runQuery() before size() can be called."); return 0; } List<String> output = exec("size " + STD_QUERY_NAME); if (output.size() != 1) { throw new InvalidDataAccessResourceUsageException( "'size' did not output the expected amount of lines [1]; was [" + output.size() + "]."); } return Integer.parseInt(output.get(0)); }
From source file:com.algoTrader.entity.security.SecurityDaoBase.java
/** * {@inheritDoc}//w w w .jav a 2 s. c o m */ @Override @SuppressWarnings("unchecked") public Object findByIdFetched(final int transform, final String queryString, final int id) { try { Query queryObject = super.getSession(false).createQuery(queryString); queryObject.setCacheable(true); queryObject.setParameter("id", new Integer(id)); 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:org.grails.datastore.mapping.redis.query.RedisQuery.java
private List unsupportedProjection(String projectionType) { throw new InvalidDataAccessResourceUsageException("Cannot use [" + projectionType + "] projection. [" + projectionType + "] projections are not currently supported."); }
From source file:org.grails.datastore.mapping.redis.query.RedisQuery.java
private PersistentProperty getValidProperty(PropertyProjection projection) { final String propName = projection.getPropertyName(); PersistentProperty prop = entityPersister.getPersistentEntity().getPropertyByName(propName); if (prop == null) { throw new InvalidDataAccessResourceUsageException("Cannot use [" + projection.getClass().getSimpleName() + "] projection on non-existent property: " + propName); } else if (!isIndexed(prop)) { throw new InvalidDataAccessResourceUsageException("Cannot use [" + projection.getClass().getSimpleName() + "] projection on non-indexed property: " + propName); }/*from www. ja v a2 s .c o m*/ return prop; }
From source file:org.grails.datastore.mapping.query.Query.java
/** * Creates an association query/*from w w w. java 2 s . co m*/ * * @param associationName The assocation name * @return The Query instance */ public AssociationQuery createQuery(String associationName) { final PersistentProperty property = entity.getPropertyByName(associationName); if (property == null || !(property instanceof Association)) { throw new InvalidDataAccessResourceUsageException("Cannot query association [" + associationName + "] of class [" + entity + "]. The specified property is not an association."); } Association association = (Association) property; final PersistentEntity associatedEntity = association.getAssociatedEntity(); return new AssociationQuery(session, associatedEntity, association); }
From source file:com.algoTrader.entity.security.SecurityDaoBase.java
/** * {@inheritDoc}//from w w w .j a v a 2 s . c om */ @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.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); } }