Search in sources :

Example 1 with EntryNotFoundException

use of io.jans.orm.exception.operation.EntryNotFoundException in project jans by JanssenProject.

the class SpannerOperationServiceImpl method deleteImpl.

private boolean deleteImpl(TableMapping tableMapping, String key) throws EntryNotFoundException {
    try {
        List<Mutation> mutations = new ArrayList<>();
        mutations.add(Mutation.delete(tableMapping.getTableName(), Key.of(key)));
        databaseClient.write(mutations);
        return true;
    } catch (SpannerException ex) {
        throw new EntryNotFoundException("Failed to delete entry", ex);
    }
}
Also used : ArrayList(java.util.ArrayList) EntryNotFoundException(io.jans.orm.exception.operation.EntryNotFoundException) Mutation(com.google.cloud.spanner.Mutation) SpannerException(com.google.cloud.spanner.SpannerException)

Example 2 with EntryNotFoundException

use of io.jans.orm.exception.operation.EntryNotFoundException in project jans by JanssenProject.

the class SqlOperationServiceImpl method deleteImpl.

private boolean deleteImpl(TableMapping tableMapping, String key) throws EntryNotFoundException {
    try {
        RelationalPathBase<Object> tableRelationalPath = buildTableRelationalPath(tableMapping);
        SQLDeleteClause sqlDeleteQuery = this.sqlQueryFactory.delete(tableRelationalPath);
        Predicate exp = ExpressionUtils.eq(Expressions.stringPath(SqlOperationService.DOC_ID), Expressions.constant(key));
        sqlDeleteQuery.where(exp);
        long rowDeleted = sqlDeleteQuery.execute();
        return rowDeleted == 1;
    } catch (QueryException ex) {
        throw new EntryNotFoundException("Failed to delete entry", ex);
    }
}
Also used : QueryException(com.querydsl.core.QueryException) SQLDeleteClause(com.querydsl.sql.dml.SQLDeleteClause) EntryNotFoundException(io.jans.orm.exception.operation.EntryNotFoundException) Predicate(com.querydsl.core.types.Predicate)

Example 3 with EntryNotFoundException

use of io.jans.orm.exception.operation.EntryNotFoundException in project jans by JanssenProject.

the class CouchbaseOperationServiceImpl method deleteRecursivelyImpl.

private boolean deleteRecursivelyImpl(BucketMapping bucketMapping, String key) throws SearchException, EntryNotFoundException {
    try {
        if (enableScopeSupport) {
            MutateLimitPath deleteQuery = Delete.deleteFrom(Expression.i(bucketMapping.getBucketName())).where(Expression.path("META().id").like(Expression.s(key + "%")));
            N1qlQueryResult result = bucketMapping.getBucket().query(deleteQuery);
            if (!result.finalSuccess()) {
                throw new SearchException(String.format("Failed to delete entries. Query: '%s'. Error: '%s', Error count: '%d'", deleteQuery, result.errors(), result.info().errorCount()), result.errors().get(0).getInt("code"));
            }
        } else {
            LOG.warn("Removing only base key without sub-tree: " + key);
            delete(key);
        }
        return true;
    } catch (CouchbaseException ex) {
        throw new EntryNotFoundException("Failed to delete entry", ex);
    }
}
Also used : CouchbaseException(com.couchbase.client.core.CouchbaseException) MutateLimitPath(com.couchbase.client.java.query.dsl.path.MutateLimitPath) EntryNotFoundException(io.jans.orm.exception.operation.EntryNotFoundException) SearchException(io.jans.orm.exception.operation.SearchException) N1qlQueryResult(com.couchbase.client.java.query.N1qlQueryResult)

Aggregations

EntryNotFoundException (io.jans.orm.exception.operation.EntryNotFoundException)3 CouchbaseException (com.couchbase.client.core.CouchbaseException)1 N1qlQueryResult (com.couchbase.client.java.query.N1qlQueryResult)1 MutateLimitPath (com.couchbase.client.java.query.dsl.path.MutateLimitPath)1 Mutation (com.google.cloud.spanner.Mutation)1 SpannerException (com.google.cloud.spanner.SpannerException)1 QueryException (com.querydsl.core.QueryException)1 Predicate (com.querydsl.core.types.Predicate)1 SQLDeleteClause (com.querydsl.sql.dml.SQLDeleteClause)1 SearchException (io.jans.orm.exception.operation.SearchException)1 ArrayList (java.util.ArrayList)1