File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
objectbox-java/src/main/java/io/objectbox
tests/objectbox-java-test/src/test/java/io/objectbox/query Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2018 ObjectBox Ltd. All rights reserved.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package io .objectbox .exception ;
18+
19+ /** Throw if {@link io.objectbox.query.Query#findUnique()} returns more than one result. */
20+ public class NonUniqueResultException extends DbException {
21+ public NonUniqueResultException (String message ) {
22+ super (message );
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ private void ensureNoComparator() {
169169 /**
170170 * Find the unique Object matching the query.
171171 *
172- * @throws io.objectbox.exception.DbException if result was not unique
172+ * @throws io.objectbox.exception.NonUniqueResultException if result was not unique
173173 */
174174 @ Nullable
175175 public T findUnique () {
Original file line number Diff line number Diff line change 3333import io .objectbox .TestEntity ;
3434import io .objectbox .TestEntity_ ;
3535import io .objectbox .TxCallback ;
36- import io .objectbox .exception .DbException ;
3736import io .objectbox .exception .DbExceptionListener ;
37+ import io .objectbox .exception .NonUniqueResultException ;
3838import io .objectbox .query .QueryBuilder .StringOrder ;
3939import io .objectbox .relation .MyObjectBox ;
4040import io .objectbox .relation .Order ;
@@ -720,7 +720,7 @@ public void onDbException(Exception e) {
720720 try {
721721 query .findUnique ();
722722 fail ("Should have thrown" );
723- } catch (DbException e ) {
723+ } catch (NonUniqueResultException e ) {
724724 assertSame (e , exs [0 ]);
725725 }
726726 }
You can’t perform that action at this time.
0 commit comments