本文整理汇总了Java中com.holonplatform.core.exceptions.DataAccessException类的典型用法代码示例。如果您正苦于以下问题:Java DataAccessException类的具体用法?Java DataAccessException怎么用?Java DataAccessException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataAccessException类属于com.holonplatform.core.exceptions包,在下文中一共展示了DataAccessException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: load
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public Stream<PropertyBox> load(QueryConfigurationProvider configuration, int offset, int limit)
throws DataAccessException {
Query q = datastore.query().target(TARGET);
if (configuration.getQueryFilter() != null) {
q.filter(configuration.getQueryFilter());
}
if (configuration.getQuerySort() != null) {
q.sort(configuration.getQuerySort());
}
if (limit > 0) {
q.limit(limit);
q.offset(offset);
}
return q.stream(TestData.PROPERTIES);
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:19,代码来源:TestPropertyQueryContainer.java
示例2: withEntityManager
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public <R> R withEntityManager(EntityManagerOperation<R> operation) {
ObjectUtils.argumentNotNull(operation, "Operation must be not null");
// initialize
final EntityManager entityManager = getEntityManager();
if (entityManager == null) {
throw new IllegalStateException(
"Obtained a null EntityManager from initializer [" + getEntityManagerInitializer() + "]");
}
try {
// execute operation
return operation.execute(entityManager);
} catch (Exception e) {
throw new DataAccessException("Failed to execute operation", e);
} finally {
getEntityManagerFinalizer().ifPresent(f -> f.finalizeEntityManager(entityManager));
}
}
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:20,代码来源:DefaultJpaDatastore.java
示例3: load
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public Stream<PropertyBox> load(QueryConfigurationProvider configuration, int offset, int limit)
throws DataAccessException {
Query q = buildQuery(configuration, true);
// paging
if (limit > 0) {
q.limit(limit);
q.offset(offset);
}
// execute
Stream<PropertyBox> results = q.stream(propertySet);
if (getItemIdentifier().isPresent()) {
return results.map(pb -> new IdentifiablePropertyBox(pb, getItemIdentifier().get()));
}
return results;
}
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:17,代码来源:DatastoreItemDataProvider.java
示例4: size
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public long size(QueryConfigurationProvider configuration) throws DataAccessException {
try {
return buildQuery(configuration, false).count();
} catch (Exception e) {
throw new DataAccessException(e);
}
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:9,代码来源:DatastoreItemDataProvider.java
示例5: load
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public Stream<PropertyBox> load(QueryConfigurationProvider configuration, int offset, int limit)
throws DataAccessException {
Query q = buildQuery(configuration, true);
// paging
if (limit > 0) {
q.limit(limit);
q.offset(offset);
}
// execute
return q.stream(propertySet);
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:13,代码来源:DatastoreItemDataProvider.java
示例6: refresh
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public ITEM refresh(ITEM item) throws UnsupportedOperationException, DataAccessException {
if (refresher == null) {
throw new UnsupportedOperationException();
}
return refresher.refresh(item);
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:8,代码来源:DefaultItemDataProvider.java
示例7: refresh
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public Item refresh(Item item) throws UnsupportedOperationException, DataAccessException {
ITEM itm = provider.refresh(adapter.restore(configuration, item));
if (itm != null) {
return adapter.adapt(configuration, itm);
}
return null;
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:9,代码来源:ContainerItemDataProvider.java
示例8: getItemId
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public ID getItemId(PropertyBox item) {
if (item != null) {
return item.getValueIfPresent(identifierProperty)
.orElseThrow(() -> new DataAccessException("The identifier property [" + identifierProperty
+ "] is not present in PropertyBox item [" + item + "]"));
}
return null;
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:10,代码来源:PropertyItemIdentifier.java
示例9: size
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public long size(QueryConfigurationProvider configuration) throws DataAccessException {
StringBuilder sb = new StringBuilder();
sb.append("select count(*) from testdata");
setupQuery(configuration, sb, false);
try (Connection connection = getConnection();
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sb.toString())) {
rs.next();
return rs.getLong(1);
} catch (SQLException e) {
throw new DataAccessException(e);
}
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:16,代码来源:TestItemQueryContainer.java
示例10: load
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public Stream<TestDataDomain> load(QueryConfigurationProvider configuration, int offset, int limit)
throws DataAccessException {
StringBuilder sb = new StringBuilder();
sb.append("select * from testdata");
setupQuery(configuration, sb, true);
if (limit > 0) {
sb.append(" limit ");
sb.append(limit);
sb.append(" offset ");
sb.append(offset);
}
List<TestDataDomain> items = new ArrayList<>();
try (Connection connection = getConnection();
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sb.toString())) {
while (rs.next()) {
TestDataDomain d = new TestDataDomain();
d.setCode(rs.getString("code"));
d.setDescription(rs.getString("description"));
d.setSequence(rs.getInt("sequence"));
d.setObsolete(rs.getInt("obsolete"));
items.add(d);
}
} catch (SQLException e) {
throw new DataAccessException(e);
}
return items.stream();
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:36,代码来源:TestItemQueryContainer.java
示例11: getConnection
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
private Connection getConnection() throws DataAccessException {
try {
return DriverManager.getConnection("jdbc:h2:mem:testdb1;INIT=RUNSCRIPT FROM 'classpath:test-db.sql'",
"sa", "");
} catch (SQLException e) {
throw new DataAccessException(e);
}
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:9,代码来源:TestItemQueryContainer.java
示例12: size
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public long size(QueryConfigurationProvider configuration) throws DataAccessException {
Query q = datastore.query().target(TARGET);
if (configuration.getQueryFilter() != null) {
q.filter(configuration.getQueryFilter());
}
return q.count();
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:9,代码来源:TestPropertyQueryContainer.java
示例13: load
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@OnShow
public void load() {
// if id parameter is not null, we are in edit mode
if (id != null) {
// load the product data
form.setValue(datastore.query().target(TARGET).filter(ID.eq(id)).findOne(PRODUCT)
// throw an exception if a product with given id was not found
.orElseThrow(() -> new DataAccessException("Data not found: " + id)));
}
// enable the Clear button if not in edit mode
clearButton.setVisible(id == null);
}
开发者ID:holon-platform,项目名称:holon-examples,代码行数:13,代码来源:Manage.java
示例14: onShow
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@OnShow
public void onShow() {
// set the view form product value
viewForm.setValue(
// load product using id parameter
datastore.query().target(TARGET).filter(ID.eq(id)).findOne(PRODUCT)
// throw an exception if not found
.orElseThrow(() -> new DataAccessException("Product not found: " + id)));
}
开发者ID:holon-platform,项目名称:holon-examples,代码行数:10,代码来源:View.java
示例15: enter
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public void enter(ViewChangeEvent event) {
// if id parameter is not null, we are in edit mode
if (id != null) {
// load the product data
form.setValue(datastore.query().target(DataTarget.named("products")).filter(MProduct.ID.eq(id))
.findOne(MProduct.PRODUCT)
// throw an exception if a product with given id was not found
.orElseThrow(() -> new DataAccessException("Data not found: " + id)));
}
}
开发者ID:holon-platform,项目名称:holon-examples,代码行数:12,代码来源:Manage.java
示例16: enter
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public void enter(ViewChangeEvent event) {
// set the view form product value
viewForm.setValue(
// load product using id parameter
datastore.query().target(DataTarget.named("products")).filter(MProduct.ID.eq(id))
.findOne(MProduct.PRODUCT)
// throw an exception if not found
.orElseThrow(() -> new DataAccessException("Product not found: " + id)));
}
开发者ID:holon-platform,项目名称:holon-examples,代码行数:11,代码来源:View.java
示例17: refresh
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public PropertyBox refresh(DataTarget<?> target, PropertyBox propertyBox) {
ObjectUtils.argumentNotNull(target, "Data target must be not null");
ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");
try {
final JdbcResolutionContext context = JdbcResolutionContext.create(this, getDialect(), AliasMode.AUTO);
final TablePrimaryKey primaryKey = getTablePrimaryKey(context, target);
return query().target(target).filter(getPrimaryKeyFilter(primaryKey, propertyBox)).findOne(propertyBox)
.orElseThrow(() -> new DataAccessException(
"No data found for primary key [" + printPrimaryKey(primaryKey, propertyBox) + "]"));
} catch (InvalidExpressionException | QueryExecutionException e) {
throw new DataAccessException("Refresh operation failed", e);
}
}
开发者ID:holon-platform,项目名称:holon-datastore-jdbc,代码行数:16,代码来源:DefaultJdbcDatastore.java
示例18: save
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public OperationResult save(DataTarget<?> target, PropertyBox propertyBox, WriteOption... options) {
ObjectUtils.argumentNotNull(target, "Data target must be not null");
ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");
boolean update = false;
try {
// check exist
Optional<TablePrimaryKey> primaryKey = resolvePrimaryKey(
JdbcResolutionContext.create(this, getDialect(), AliasMode.UNSUPPORTED), target);
if (!primaryKey.isPresent()) {
LOGGER.warn("(save) Cannot obtain the primary key for target [" + target
+ "]: an INSERT operation will be performed by default");
return insert(target, propertyBox);
} else {
final Path<?> singleKey = (primaryKey.get().getKeys().length == 1) ? primaryKey.get().getKeys()[0]
: null;
update = getOptionalPrimaryKeyFilter(primaryKey.get(), propertyBox).map(f -> {
Query q = query().target(target).filter(f);
if (singleKey != null) {
return q.findOne(PathProperty.create(singleKey).count()).orElse(0L) > 0;
}
return q.count() > 0;
}).orElse(false);
}
} catch (Exception e) {
throw new DataAccessException("Failed to execute existence query to discern insert/update operation", e);
}
return update ? update(target, propertyBox, options) : insert(target, propertyBox, options);
}
开发者ID:holon-platform,项目名称:holon-datastore-jdbc,代码行数:34,代码来源:DefaultJdbcDatastore.java
示例19: update
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public OperationResult update(DataTarget<?> target, PropertyBox propertyBox, WriteOption... options) {
ObjectUtils.argumentNotNull(target, "Data target must be not null");
ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");
final JdbcResolutionContext context = JdbcResolutionContext.create(this, getDialect(), AliasMode.UNSUPPORTED);
final String sql;
try {
OperationStructure.Builder builder = OperationStructure.builder(OperationType.UPDATE, target);
// valid Paths
propertyBox.stream().filter(p -> Path.class.isAssignableFrom(p.getClass())).map(p -> (Path<?>) p)
.collect(Collectors.toList()).forEach(p -> {
builder.withValue(p, getPathValue(p, propertyBox, false));
});
// primary key filter
builder.withFilter(getPrimaryKeyFilter(getTablePrimaryKey(context, target), propertyBox));
// resolve OperationStructure
sql = JdbcDatastoreUtils.resolveExpression(this, builder.build(), SQLToken.class, context).getValue();
} catch (InvalidExpressionException e) {
throw new DataAccessException("Failed to configure update operation", e);
}
return withConnection(c -> {
PreparedSql preparedSql = JdbcDatastoreUtils.prepareSql(sql, context);
trace(preparedSql.getSql());
try (PreparedStatement stmt = preparedSql.createStatement(c, getDialect())) {
int result = stmt.executeUpdate();
return OperationResult.builder().type(OperationType.UPDATE).affectedCount(result).build();
}
});
}
开发者ID:holon-platform,项目名称:holon-datastore-jdbc,代码行数:39,代码来源:DefaultJdbcDatastore.java
示例20: delete
import com.holonplatform.core.exceptions.DataAccessException; //导入依赖的package包/类
@Override
public OperationResult delete(DataTarget<?> target, PropertyBox propertyBox, WriteOption... options) {
ObjectUtils.argumentNotNull(target, "Data target must be not null");
ObjectUtils.argumentNotNull(propertyBox, "PropertyBox must be not null");
final JdbcResolutionContext context = JdbcResolutionContext.create(this, getDialect(),
getDialect().deleteStatementAliasSupported() ? AliasMode.AUTO : AliasMode.UNSUPPORTED);
final String sql;
try {
OperationStructure.Builder builder = OperationStructure.builder(OperationType.DELETE, target);
// primary key filter
builder.withFilter(getPrimaryKeyFilter(getTablePrimaryKey(context, target), propertyBox));
// resolve OperationStructure
sql = JdbcDatastoreUtils.resolveExpression(this, builder.build(), SQLToken.class, context).getValue();
} catch (InvalidExpressionException e) {
throw new DataAccessException("Failed to configure delete operation", e);
}
// execute
return withConnection(c -> {
PreparedSql preparedSql = JdbcDatastoreUtils.prepareSql(sql, context);
trace(preparedSql.getSql());
try (PreparedStatement stmt = preparedSql.createStatement(c, getDialect())) {
int deleted = stmt.executeUpdate();
return OperationResult.builder().type(OperationType.DELETE).affectedCount(deleted).build();
}
});
}
开发者ID:holon-platform,项目名称:holon-datastore-jdbc,代码行数:36,代码来源:DefaultJdbcDatastore.java
注:本文中的com.holonplatform.core.exceptions.DataAccessException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论