本文整理汇总了Java中com.holonplatform.core.exceptions.DataAccessException类的典型用法代码示例。如果您正苦于以下问题:Java DataAccessException类的具体用法?Java DataAccessException怎么用?Java DataAccessException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataAccessException类属于com.holonplatform.core.exceptions包,在下文中一共展示了DataAccessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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));
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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();
}
示例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);
}
示例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)));
}
示例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)));
}
}