本文整理汇总了Java中org.springframework.dao.InvalidDataAccessResourceUsageException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidDataAccessResourceUsageException类的具体用法?Java InvalidDataAccessResourceUsageException怎么用?Java InvalidDataAccessResourceUsageException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidDataAccessResourceUsageException类属于org.springframework.dao包,在下文中一共展示了InvalidDataAccessResourceUsageException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public <T extends IPOMObject> T save(T entity) {
for (Map.Entry<String, IDataStoreDAO> dataStoreEntry : dataStores.entrySet()) {
String dataSource = dataStoreEntry.getKey();
if (!environment.acceptsProfiles(dataSource)) continue;
IDataStoreDAO dao = dataStoreEntry.getValue();
if (dao == null) {
throw new InvalidDataAccessResourceUsageException("No implementation of IDataStoreDAO registered under key '" + dataStoreEntry.getKey() + "'");
} else {
Timer.Context timer = metrics.timer(metrics.name("vpr.persist", ClassUtils.getShortNameAsProperty(entity.getClass()), dataSource)).time();
Stopwatch stopwatch = new Stopwatch().start();
dao.save(entity);
LOGGER.debug("TIME ELAPSED saving " + entity.getUid() + " to " + dataStoreEntry.getKey() + " : " + stopwatch.elapsed(TimeUnit.MILLISECONDS));
timer.stop();
}
}
return entity;
}
示例2: write
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
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);
}
}
}
}
}
示例3: delete
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public <T extends IPOMObject> void delete(T entity) {
for (Map.Entry<String, IDataStoreDAO> dataStoreEntry : dataStores.entrySet()) {
String dataSource = dataStoreEntry.getKey();
if (!environment.acceptsProfiles(dataSource)) continue;
IDataStoreDAO dao = dataStoreEntry.getValue();
if (dao == null) {
throw new InvalidDataAccessResourceUsageException("No implementation of IDataStoreDAO registered under key '" + dataStoreEntry.getKey() + "'");
} else {
Timer.Context timer = metrics.timer(metrics.name("vpr.delete", ClassUtils.getShortNameAsProperty(entity.getClass()), dataSource)).time();
dao.delete(entity);
timer.stop();
}
}
}
示例4: getDb
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public DB getDb() {
// Multi tenancy database name selection
final String databaseName;
try {
databaseName = tenantProvider.getDatabaseName();
} catch (Exception e) {
throw new InvalidDataAccessResourceUsageException("Unable to retrieve database name.", e);
}
Assert.hasText(databaseName, "Database name must not be empty.");
LOGGER.debug("Using '{}' as Mongo database.", databaseName);
// Get MongoDB database using tenant information
MongoClient mongoClient = mongoClientProvider.get(tenantProvider);
return MongoDbUtils.getDB(mongoClient, databaseName);
}
示例5: saveGraphVersion
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public void saveGraphVersion(IWayGraphVersionMetadata graphMetadata) {
Object[] args = new Object[20];
try {
args[0] = convertToArray(getJdbcTemplate().getDataSource().getConnection(), graphMetadata.getAccessTypes());
} catch (SQLException e) {
throw new InvalidDataAccessResourceUsageException(e.getMessage(), e);
}
args[1] = graphMetadata.getConnectionsCount();
args[2] = "SRID=4326;"+wktWriter.write(graphMetadata.getCoveredArea());
args[3] = graphMetadata.getState().name();
args[4] = graphMetadata.getCreationTimestamp();
args[5] = graphMetadata.getCreator();
args[6] = graphMetadata.getDescription();
args[7] = graphMetadata.getGraphId();
args[8] = graphMetadata.getGraphName();
args[9] = graphMetadata.getOriginGraphName();
args[10] = graphMetadata.getOriginUrl();
args[11] = graphMetadata.getOriginVersion();
args[12] = graphMetadata.getSegmentsCount();
args[13] = graphMetadata.getSource().getId();
args[14] = graphMetadata.getStorageTimestamp();
if (graphMetadata.getTags() != null) {
args[15] = graphMetadata.getTags();
} else {
args[15] = null;
}
args[16] = graphMetadata.getType();
args[17] = graphMetadata.getValidFrom();
args[18] = graphMetadata.getValidTo();
args[19] = graphMetadata.getVersion();
getJdbcTemplate().update("INSERT INTO " + schema + METADATA_TABLE_NAME + " (accesstypes, connections_count, covered_area," +
"state, creation_timestamp, creator, description, graph_id, graphname, origin_graphname, origin_url, origin_version, " +
"segments_count, source_id, storage_timestamp, tags, type, valid_from, valid_to, version) " +
"VALUES (?,?,ST_GeomFromEWKT(?),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", args);
}
示例6: updateGraphVersion
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public void updateGraphVersion(IWayGraphVersionMetadata graphMetadata) {
Object[] args = new Object[18];
try {
args[0] = convertToArray(getJdbcTemplate().getDataSource().getConnection(), graphMetadata.getAccessTypes());
} catch (SQLException e) {
throw new InvalidDataAccessResourceUsageException(e.getMessage(), e);
}
args[1] = graphMetadata.getConnectionsCount();
args[2] = "SRID=4326;"+wktWriter.write(graphMetadata.getCoveredArea());
args[3] = graphMetadata.getCreationTimestamp();
args[4] = graphMetadata.getCreator();
args[5] = graphMetadata.getDescription();
args[6] = graphMetadata.getOriginGraphName();
args[7] = graphMetadata.getOriginUrl();
args[8] = graphMetadata.getOriginVersion();
args[9] = graphMetadata.getSegmentsCount();
args[10] = graphMetadata.getSource().getId();
args[11] = graphMetadata.getStorageTimestamp();
if (graphMetadata.getTags() != null) {
args[12] = graphMetadata.getTags();
} else {
args[12] = null;
}
args[13] = graphMetadata.getType();
args[14] = graphMetadata.getValidFrom();
args[15] = graphMetadata.getValidTo();
args[16] = graphMetadata.getGraphName();
args[17] = graphMetadata.getVersion();
getJdbcTemplate().update("UPDATE " + schema + METADATA_TABLE_NAME + " SET accesstypes=?, connections_count=?, covered_area=ST_GeomFromEWKT(?)," +
"creation_timestamp=?, creator=?, description=?, origin_graphname=?, origin_url=?, origin_version=?, " +
"segments_count=?, source_id=?, storage_timestamp=?, tags=?, type=?, valid_from=?, valid_to=? " +
"WHERE graphname =? AND version=?", args);
}
示例7: createPreparedStatement
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement ps;
if (generatedKeysColumnNames != null || returnGeneratedKeys) {
try {
if (generatedKeysColumnNames != null) {
ps = con.prepareStatement(this.actualSql, generatedKeysColumnNames);
}
else {
ps = con.prepareStatement(this.actualSql, PreparedStatement.RETURN_GENERATED_KEYS);
}
}
catch (AbstractMethodError err) {
throw new InvalidDataAccessResourceUsageException(
"Your JDBC driver is not compliant with JDBC 3.0 - " +
"it does not support retrieval of auto-generated keys", err);
}
}
else if (resultSetType == ResultSet.TYPE_FORWARD_ONLY && !updatableResults) {
ps = con.prepareStatement(this.actualSql);
}
else {
ps = con.prepareStatement(this.actualSql, resultSetType,
updatableResults ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
}
setValues(ps);
return ps;
}
示例8: getValidProperty
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
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);
}
return prop;
}
示例9: getAndValidateProperty
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
private PersistentProperty getAndValidateProperty(RedisEntityPersister entityPersister, String property) {
final PersistentEntity entity = entityPersister.getPersistentEntity();
PersistentProperty prop = entity.getPropertyByName(property);
if (prop == null) {
throw new InvalidDataAccessResourceUsageException("Cannot execute between query on property [" +
property + "] of class [" + entity + "]. Property does not exist.");
}
return prop;
}
示例10: assertIndexed
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
private void assertIndexed(String property, PersistentProperty prop) {
if (prop == null) {
throw new InvalidDataAccessResourceUsageException("Cannot execute query. Entity [" +
getEntity() + "] does not declare a property named [" + property + "]");
}
if (!isIndexed(prop)) {
throw new InvalidDataAccessResourceUsageException("Cannot query class [" +
getEntity() + "] on property [" + prop + "]. The property is not indexed!");
}
}
示例11: initialize
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
/**
* Initialize this container. If this container is not configured with "activeWhenPrimary" flag
* set to <code>true</code> will call {@link #doStart()} (if it is set to <code>true</code>,
* lifecycle of the container will be controlled by the current space mode).
* {@link #doInitialize()} will be called for additional initialization after the possible
* {@link #doStart()} call.
*
* @see #onApplicationEvent(org.springframework.context.ApplicationEvent)
*/
public void initialize() throws DataAccessException {
initializeTransactionManager();
initializeTemplate();
initializeExceptionHandler();
synchronized (this.lifecycleMonitor) {
this.active = true;
this.lifecycleMonitor.notifyAll();
}
doInitialize();
if (!activeWhenPrimary) {
doStart();
}
if (registerSpaceModeListener) {
SpaceMode currentMode = SpaceMode.PRIMARY;
if (!SpaceUtils.isRemoteProtocol(gigaSpace.getSpace())) {
primaryBackupListener = new PrimaryBackupListener();
try {
IJSpace clusterMemberSpace = SpaceUtils.getClusterMemberSpace(gigaSpace.getSpace());
ISpaceModeListener remoteListener = (ISpaceModeListener) clusterMemberSpace.getDirectProxy().getStubHandler()
.exportObject(primaryBackupListener);
currentMode = ((IInternalRemoteJSpaceAdmin) clusterMemberSpace.getAdmin()).addSpaceModeListener(remoteListener);
} catch (RemoteException e) {
throw new InvalidDataAccessResourceUsageException("Failed to register space mode listener with space [" + gigaSpace.getSpace()
+ "]", e);
}
}
SpaceInitializationIndicator.setInitializer();
try {
onApplicationEvent(new BeforeSpaceModeChangeEvent(gigaSpace.getSpace(), currentMode));
onApplicationEvent(new AfterSpaceModeChangeEvent(gigaSpace.getSpace(), currentMode));
} finally {
SpaceInitializationIndicator.unsetInitializer();
}
}
}
示例12: setResponse
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public void setResponse(NamedList<Object> response) {
super.setResponse(response);
try {
root = new ObjectMapper().readTree((String) getResponse().get("json"));
} catch (Exception e) {
throw new InvalidDataAccessResourceUsageException("Unable to parse json from response.", e);
}
}
示例13: processResponse
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public NamedList<Object> processResponse(InputStream body, String encoding) {
NamedList<Object> result = new NamedList<Object>();
try {
result.add("json", StreamUtils.copyToString(body, Charset.forName(encoding)));
} catch (IOException e) {
throw new InvalidDataAccessResourceUsageException("Unable to read json from stream.", e);
}
return result;
}
示例14: createMongoClient
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
protected MongoClient createMongoClient(MongoClientURI uri) {
try {
return new MongoClient(uri);
} catch (Exception e) {
// 3.x client throws UnknownHostException, keep catch block for compatibility with 3.x version
throw new InvalidDataAccessResourceUsageException("Unable to retrieve host information.", e);
}
}
示例15: get
import org.springframework.dao.InvalidDataAccessResourceUsageException; //导入依赖的package包/类
@Override
public MongoClient get(TenantInformationProvider provider) {
try {
return cache.get(provider.getDatabaseURI());
} catch (Exception e) {
throw new InvalidDataAccessResourceUsageException("Unable to retrieve client.", e);
}
}