-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#177: added Query, selection for StatementFactory, etc.
- Loading branch information
Showing
45 changed files
with
893 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
mmm-util-query/src/main/java/net/sf/mmm/util/query/api/Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package net.sf.mmm.util.query.api; | ||
|
||
/** | ||
* This is the abstract interface of a {@link Command} that can be executed against a database as {@link #getSql() SQL}. | ||
* It is either a {@link Query} or a {@link net.sf.mmm.util.query.api.statement.Statement}. | ||
* | ||
* @author hohwille | ||
* @since 8.0.0 | ||
*/ | ||
public abstract interface Command { | ||
|
||
/** | ||
* @return the current SQL {@link String} of this {@link Command}. In case of a | ||
* {@link net.sf.mmm.util.query.api.statement.Statement} it may only be an SQL fragment as the final operation | ||
* such as {@link net.sf.mmm.util.query.api.statement.SelectStatement#fetch()} will complete the statement. | ||
*/ | ||
String getSql(); | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
mmm-util-query/src/main/java/net/sf/mmm/util/query/api/ListQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package net.sf.mmm.util.query.api; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
/** | ||
* This is the interface for a regular {@link Query} that returns the {@link List} of matching objects. | ||
* | ||
* @param <E> the generic type of the {@link List}-{@link List#get(int) elements}. | ||
* | ||
* @see net.sf.mmm.util.query.api.statement.SelectStatement#query() | ||
* | ||
* @author hohwille | ||
* @since 8.0.0 | ||
*/ | ||
public interface ListQuery<E> extends Query<List<E>>, Iterable<E> { | ||
|
||
/** | ||
* {@link #execute() Executes} the query and returns the matching objects as {@link Iterator}. This method may be | ||
* overridden for database technology implementations that have native support for {@link Iterator} (unlike | ||
* {@link net.sf.mmm.util.query.base.statement.jpql.Jpql}). In such case this method is way more efficient if you only | ||
* need to iterate the results to a specific point without the need to know the {@link List#size() number of matches}. | ||
* If possible you shall prefer this method over {@link #execute()}. | ||
* | ||
* @return an {@link Iterator} of the {@link #execute() results}. | ||
*/ | ||
default Iterator<E> iterator() { | ||
|
||
return execute().iterator(); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
mmm-util-query/src/main/java/net/sf/mmm/util/query/api/NumberQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package net.sf.mmm.util.query.api; | ||
|
||
/** | ||
* A {@link Query} that {@link #execute() results} in a {@link Number}. | ||
* | ||
* @param <E> the generic type of the {@link #execute() result}. | ||
* | ||
* @author hohwille | ||
* @since 8.0.0 | ||
*/ | ||
public interface NumberQuery<E extends Number & Comparable<?>> extends Query<E> { | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
mmm-util-query/src/main/java/net/sf/mmm/util/query/api/Query.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package net.sf.mmm.util.query.api; | ||
|
||
/** | ||
* This is the interface for a query that is the {@link net.sf.mmm.util.query.api.statement.SelectStatement#query() | ||
* result} of a {@link net.sf.mmm.util.query.api.statement.SelectStatement}.<br/> | ||
* Besides {@link #execute() executing} the {@link Query} you can also reuse it as a sub-query in more complex | ||
* {@link net.sf.mmm.util.query.api.statement.Statement}s. | ||
* | ||
* @param <E> the generic type of the {@link #execute() result}. | ||
* | ||
* @author hohwille | ||
* @since 8.0.0 | ||
*/ | ||
public interface Query<E> extends Command { | ||
|
||
/** | ||
* Executes the {@link Query} {@link Command} and returns the result. | ||
* | ||
* @return the result of the {@link Query} execution. | ||
*/ | ||
E execute(); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
mmm-util-query/src/main/java/net/sf/mmm/util/query/api/SingleQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package net.sf.mmm.util.query.api; | ||
|
||
import net.sf.mmm.util.exception.api.ObjectNotFoundException; | ||
|
||
/** | ||
* This is the interface for a {@link Query} that can only match a single result. | ||
* | ||
* @param <E> the generic type of the {@link #execute() result}. | ||
* @see #executeRequired() | ||
* | ||
* @author hohwille | ||
* @since 8.0.0 | ||
*/ | ||
public interface SingleQuery<E> extends Query<E> { | ||
|
||
/** | ||
* @throws ObjectNotFoundException if the query had no match. | ||
* @return the result of {@link #execute()} but never {@code null}. | ||
*/ | ||
E executeRequired() throws ObjectNotFoundException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.