List of usage examples for org.springframework.dao InvalidDataAccessApiUsageException InvalidDataAccessApiUsageException
public InvalidDataAccessApiUsageException(String msg)
From source file:com.joyveb.dbpimpl.cass.prepare.mapping.BasicCassandraPersistentProperty.java
private DataType qualifyAnnotatedType(Qualify annotation) { DataType.Name type = annotation.type(); if (type.isCollection()) { switch (type) { case MAP: ensureTypeArguments(annotation.typeArguments().length, 2); return DataType.map(resolvePrimitiveType(annotation.typeArguments()[0]), resolvePrimitiveType(annotation.typeArguments()[1])); case LIST: ensureTypeArguments(annotation.typeArguments().length, 1); return DataType.list(resolvePrimitiveType(annotation.typeArguments()[0])); case SET: ensureTypeArguments(annotation.typeArguments().length, 1); return DataType.set(resolvePrimitiveType(annotation.typeArguments()[0])); default:/*from w ww . jav a 2s . c o m*/ throw new InvalidDataAccessApiUsageException( "unknown collection DataType for property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName()); } } else { return CassandraSimpleTypes.resolvePrimitive(type); } }
From source file:com.turbospaces.spaces.AbstractJSpace.java
@Override public void notify(final Object template, final SpaceNotificationListener listener, final int modifiers) { boolean isMatchById = SpaceModifiers.isMatchById(modifiers); BO bo = configuration.boFor(template.getClass()); CacheStoreEntryWrapper cacheStoreEntryWrapper = CacheStoreEntryWrapper.writeValueOf(bo, template); if (isMatchById && cacheStoreEntryWrapper.getId() == null) throw new InvalidDataAccessApiUsageException(String.format( "Illegal attempt to perform matching by ID when id is not provided. Template = %s", template)); this.notificationContext.add(new NotificationContext(cacheStoreEntryWrapper, listener, modifiers)); }
From source file:com.joyveb.dbpimpl.cass.prepare.core.CassandraSessionFactoryBean.java
public String getTableName(Class<?> entityClass) { if (entityClass == null) { throw new InvalidDataAccessApiUsageException( "No class parameter provided, entity table name can't be determined!"); }//from w w w. j a v a 2 s . c o m CassandraPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass); if (entity == null) { throw new InvalidDataAccessApiUsageException( "No Persitent Entity information found for the class " + entityClass.getName()); } return entity.getTableName(); }
From source file:com.frank.search.solr.core.query.result.DelegatingCursor.java
private void validateState() { if (isReady() || isClosed()) { throw new InvalidDataAccessApiUsageException( "Cannot access closed cursor. Did you forget to call open()?"); }//from www . j a v a2 s . c o m }
From source file:com.frank.search.solr.repository.query.SolrQueryCreator.java
private Criteria from(Type type, Criteria instance, Iterator<?> parameters) { Criteria criteria = instance;// ww w . j av a 2s. c o m if (criteria == null) { criteria = new Criteria(); } switch (type) { case TRUE: return criteria.is(true); case FALSE: return criteria.is(false); case SIMPLE_PROPERTY: return criteria.is(appendBoostAndGetParameterValue(criteria, parameters)); case NEGATING_SIMPLE_PROPERTY: return criteria.is(appendBoostAndGetParameterValue(criteria, parameters)).not(); case IS_NULL: return criteria.isNull(); case IS_NOT_NULL: return criteria.isNotNull(); case REGEX: return criteria.expression(appendBoostAndGetParameterValue(criteria, parameters).toString()); case LIKE: case STARTING_WITH: return criteria.startsWith(asStringArray(appendBoostAndGetParameterValue(criteria, parameters))); case NOT_LIKE: return criteria.startsWith(asStringArray(appendBoostAndGetParameterValue(criteria, parameters))).not(); case ENDING_WITH: return criteria.endsWith(asStringArray(appendBoostAndGetParameterValue(criteria, parameters))); case CONTAINING: return criteria.contains(asStringArray(appendBoostAndGetParameterValue(criteria, parameters))); case AFTER: case GREATER_THAN: return criteria.greaterThan(appendBoostAndGetParameterValue(criteria, parameters)); case GREATER_THAN_EQUAL: return criteria.greaterThanEqual(appendBoostAndGetParameterValue(criteria, parameters)); case BEFORE: case LESS_THAN: return criteria.lessThan(appendBoostAndGetParameterValue(criteria, parameters)); case LESS_THAN_EQUAL: return criteria.lessThanEqual(appendBoostAndGetParameterValue(criteria, parameters)); case BETWEEN: return criteria.between(appendBoostAndGetParameterValue(criteria, parameters), appendBoostAndGetParameterValue(criteria, parameters)); case IN: return criteria.in(asArray(appendBoostAndGetParameterValue(criteria, parameters))); case NOT_IN: return criteria.in(asArray(appendBoostAndGetParameterValue(criteria, parameters))).not(); case NEAR: return createNearCriteria(parameters, criteria); case WITHIN: return criteria.within((Point) getBindableValue((BindableSolrParameter) parameters.next()), (Distance) getBindableValue((BindableSolrParameter) parameters.next())); default: throw new InvalidDataAccessApiUsageException("Illegal criteria found '" + type + "'."); } }
From source file:com.gzj.tulip.jade.statement.UpdateQuerier.java
private Object executeBatch(StatementRuntime... runtimes) { int[] updatedArray = new int[runtimes.length]; Map<String, List<StatementRuntime>> batchs = new HashMap<String, List<StatementRuntime>>(); for (int i = 0; i < runtimes.length; i++) { StatementRuntime runtime = runtimes[i]; List<StatementRuntime> batch = batchs.get(runtime.getSQL()); if (batch == null) { batch = new ArrayList<StatementRuntime>(runtimes.length); batchs.put(runtime.getSQL(), batch); }/* w w w . j a va 2 s.c om*/ runtime.setAttribute("_index_at_batch_", i); // runtimebatch? batch.add(runtime); } // TODO: batch?(??)~ for (Map.Entry<String, List<StatementRuntime>> batch : batchs.entrySet()) { String sql = batch.getKey(); List<StatementRuntime> batchRuntimes = batch.getValue(); StatementRuntime runtime = batchRuntimes.get(0); DataAccess dataAccess = dataAccessFactory.getDataAccess(// runtime.getMetaData(), runtime.getAttributes()); List<Object[]> argsList = new ArrayList<Object[]>(batchRuntimes.size()); for (StatementRuntime batchRuntime : batchRuntimes) { argsList.add(batchRuntime.getArgs()); } int[] batchResult = dataAccess.batchUpdate(sql, argsList); if (batchs.size() == 1) { updatedArray = batchResult; } else { int index_at_sub_batch = 0; for (StatementRuntime batchRuntime : batchRuntimes) { Integer _index_at_batch_ = batchRuntime.getAttribute("_index_at_batch_"); updatedArray[_index_at_batch_] = batchResult[index_at_sub_batch++]; } } } if (returnType == void.class) { return null; } if (returnType == int[].class) { return updatedArray; } if (returnType == Integer.class || returnType == Boolean.class) { int updated = 0; for (int value : updatedArray) { updated += value; } return returnType == Boolean.class ? updated > 0 : updated; } throw new InvalidDataAccessApiUsageException( "bad return type for batch update: " + runtimes[0].getMetaData().getMethod()); }
From source file:com.joyveb.dbpimpl.cass.prepare.mapping.BasicCassandraPersistentProperty.java
DataType resolvePrimitiveType(DataType.Name typeName) { DataType dataType = CassandraSimpleTypes.resolvePrimitive(typeName); if (dataType == null) { throw new InvalidDataAccessApiUsageException( "only primitive types are allowed inside collections for the property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName()); }/* w w w. j a v a 2s .c o m*/ return dataType; }
From source file:com.clican.pluto.common.support.spring.BeanPropertyRowMapper.java
/** * Extract the values for all columns in the current row. * <p>/* www .jav a 2 s. com*/ * Utilizes public setters and result set metadata. * * @see java.sql.ResultSetMetaData */ public Object mapRow(ResultSet rs, int rowNumber) throws SQLException { Assert.state(this.mappedClass != null, "Mapped class was not specified"); Object mappedObject = BeanUtils.instantiateClass(this.mappedClass); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(mappedObject); initBeanWrapper(bw); ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); Set<String> populatedProperties = (isCheckFullyPopulated() ? new HashSet<String>() : null); for (int index = 1; index <= columnCount; index++) { String column = JdbcUtils.lookupColumnName(rsmd, index).toLowerCase(); PropertyDescriptor pd = (PropertyDescriptor) this.mappedFields.get(column); if (pd != null) { try { Object value = getColumnValue(rs, index, pd); if (logger.isDebugEnabled() && rowNumber == 0) { logger.debug("Mapping column '" + column + "' to property '" + pd.getName() + "' of type " + pd.getPropertyType()); } bw.setPropertyValue(pd.getName(), value); if (populatedProperties != null) { populatedProperties.add(pd.getName()); } } catch (NotWritablePropertyException ex) { throw new DataRetrievalFailureException( "Unable to map column " + column + " to property " + pd.getName(), ex); } } } if (populatedProperties != null && !populatedProperties.equals(this.mappedProperties)) { throw new InvalidDataAccessApiUsageException("Given ResultSet does not contain all fields " + "necessary to populate object of class [" + this.mappedClass + "]: " + this.mappedProperties); } return mappedObject; }
From source file:com.joyveb.dbpimpl.cass.prepare.mapping.BasicCassandraPersistentProperty.java
DataType autodetectPrimitiveType(Class<?> javaType) { DataType dataType = CassandraSimpleTypes.autodetectPrimitive(javaType); if (dataType == null) { throw new InvalidDataAccessApiUsageException( "only primitive types are allowed inside collections for the property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName()); }//from ww w . j ava2 s . c o m return dataType; }
From source file:paillard.florent.springframework.simplejdbcupdate.AbstractJdbcUpdate.java
/** * Compile this JdbcUpdate using provided parameters and meta data plus * other settings. This finalizes the configuration for this object and * subsequent attempts to compile are ignored. This will be implicitly * called the first time an un-compiled update is executed. * /*ww w . ja v a2 s . com*/ * @throws org.springframework.dao.InvalidDataAccessApiUsageException * if the object hasn't been correctly initialized, for example * if no DataSource has been provided */ public synchronized final void compile() throws InvalidDataAccessApiUsageException { if (!isCompiled()) { if (getTableName() == null) { throw new InvalidDataAccessApiUsageException("Table name is required"); } try { this.jdbcTemplate.afterPropertiesSet(); } catch (IllegalArgumentException ex) { throw new InvalidDataAccessApiUsageException(ex.getMessage()); } compileInternal(); this.compiled = true; if (logger.isDebugEnabled()) { logger.debug("JdbcUpdate for table [" + getTableName() + "] compiled"); } } }