Skip to content

Commit fa92e7a

Browse files
authored
Merge pull request #3416 from ebean-orm/feature/querybean-gen-suppresswarnings
Change QueryBean to use protected constructors, suppress warning on generated query beans
2 parents 7b2128b + 1823ef2 commit fa92e7a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

ebean-querybean/src/main/java/io/ebean/typequery/QueryBean.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public abstract class QueryBean<T, R> implements IQueryBean<T, R> {
8888
/**
8989
* Construct using the type of bean to query on and the default database.
9090
*/
91-
public QueryBean(Class<T> beanType) {
91+
protected QueryBean(Class<T> beanType) {
9292
this(beanType, DB.getDefault());
9393
}
9494

9595
/**
9696
* Construct using the type of bean to query on and a given database.
9797
*/
98-
public QueryBean(Class<T> beanType, Database database) {
98+
protected QueryBean(Class<T> beanType, Database database) {
9999
this(database.find(beanType));
100100
}
101101

@@ -119,7 +119,7 @@ protected QueryBean(Class<T> beanType, Database database, Transaction transactio
119119
* Construct using a query.
120120
*/
121121
@SuppressWarnings("unchecked")
122-
public QueryBean(Query<T> query) {
122+
protected QueryBean(Query<T> query) {
123123
this.query = query;
124124
this.root = (R) this;
125125
}
@@ -129,7 +129,7 @@ public QueryBean(Query<T> query) {
129129
* values for select() and fetch().
130130
*/
131131
@SuppressWarnings("unchecked")
132-
public QueryBean(boolean aliasDummy) {
132+
protected QueryBean(boolean aliasDummy) {
133133
this.query = null;
134134
this.root = (R) this;
135135
}

querybean-generator/src/main/java/io/ebean/querybean/generator/SimpleQueryBeanWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ private void writeFields() {
217217
private void writeClass() {
218218
writer.append("/**").eol();
219219
writer.append(" * Query bean for %s.", shortName).eol();
220-
writer.append(" * ").eol();
220+
writer.append(" * <p>").eol();
221221
writer.append(" * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.").eol();
222222
writer.append(" */").eol();
223+
writer.append("@SuppressWarnings(\"unused\")").eol();
223224
writer.append(Constants.AT_GENERATED).eol();
224225
if (embeddable) {
225226
writer.append("public final class Q%s {", shortName).eol();
@@ -285,7 +286,7 @@ private void writeAssocClass() {
285286
private void writeAssocFilterMany() {
286287
writer.eol();
287288
writer.append(" @SuppressWarnings({\"unchecked\", \"rawtypes\"})").eol();
288-
writer.append(" public final R filterMany(java.util.function.Consumer<Q%s> apply) {", shortName).eol();
289+
writer.append(" public R filterMany(java.util.function.Consumer<Q%s> apply) {", shortName).eol();
289290
writer.append(" final io.ebean.ExpressionList list = io.ebean.Expr.factory().expressionList();", shortName).eol();
290291
writer.append(" final var qb = new Q%s(list);", shortName).eol();
291292
writer.append(" apply.accept(qb);").eol();

0 commit comments

Comments
 (0)