Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3251 - QueryBeans: Entities can not have same name as some Ebean API… #3253

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

interface Constants {

String AT_GENERATED = "@Generated(\"io.ebean.querybean.generator\")";

String AT_TYPEQUERYBEAN = "@TypeQueryBean(\"v1\")";
String AT_GENERATED = "@io.ebean.typequery.Generated(\"io.ebean.querybean.generator\")";
String AT_TYPEQUERYBEAN = "@io.ebean.typequery.TypeQueryBean(\"v1\")";
String GENERATED = "io.ebean.typequery.Generated";

String MAPPED_SUPERCLASS = "jakarta.persistence.MappedSuperclass";
Expand All @@ -23,12 +22,7 @@ interface Constants {
String TQROOTBEAN = "io.ebean.typequery.TQRootBean";
String TQASSOCBEAN = "io.ebean.typequery.TQAssocBean";
String TQASSOC = "io.ebean.typequery.TQAssoc";
String TYPEQUERYBEAN = "io.ebean.typequery.TypeQueryBean";
String DATABASE = "io.ebean.Database";
String DB = "io.ebean.DB";
String FETCHGROUP = "io.ebean.FetchGroup";
String QUERY = "io.ebean.Query";
String TRANSACTION = "io.ebean.Transaction";

String MODULEINFO = "io.ebean.config.ModuleInfo";
String METAINF_MANIFEST = "META-INF/ebean-generated-info.mf";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,12 @@ private boolean isEmbeddable() {
}

private void gatherPropertyDetails() {
importTypes.add(Constants.GENERATED);
importTypes.add(beanFullName);
importTypes.add(Constants.TYPEQUERYBEAN);
if (embeddable) {
importTypes.add(Constants.TQASSOC);
} else {
importTypes.add(Constants.TQASSOCBEAN);
importTypes.add(Constants.TQROOTBEAN);
importTypes.add(Constants.DATABASE);
importTypes.add(Constants.FETCHGROUP);
importTypes.add(Constants.QUERY);
importTypes.add(Constants.TRANSACTION);
importTypes.add(Constants.CONSUMER);
importTypes.add(Constants.EXPR);
importTypes.add(Constants.EXPRESSIONLIST);
}

if (implementsInterface != null) {
Expand Down Expand Up @@ -170,7 +161,7 @@ private void writeConstructors() {
writer.append(" * }</pre>").eol();
writer.append(" */").eol();
writer.append(" public static Q%s forFetchGroup() {", shortName).eol();
writer.append(" return new Q%s(FetchGroup.queryFor(%s.class));", shortName, shortName).eol();
writer.append(" return new Q%s(io.ebean.FetchGroup.queryFor(%s.class));", shortName, shortName).eol();
writer.append(" }").eol();
writer.eol();

Expand All @@ -186,7 +177,7 @@ private void writeConstructors() {
writer.eol();

writer.append(" /** Construct with a given transaction */").eol();
writer.append(" public Q%s(Transaction transaction) {", shortName).eol();
writer.append(" public Q%s(io.ebean.Transaction transaction) {", shortName).eol();
if (dbName == null) {
writer.append(" super(%s.class, transaction);", shortName).eol();
} else {
Expand All @@ -196,7 +187,7 @@ private void writeConstructors() {

writer.eol();
writer.append(" /** Construct with a given Database */").eol();
writer.append(" public Q%s(Database database) {", shortName).eol();
writer.append(" public Q%s(io.ebean.Database database) {", shortName).eol();
writer.append(" super(%s.class, database);", shortName).eol();
writer.append(" }").eol();
writer.eol();
Expand All @@ -209,13 +200,13 @@ private void writeConstructors() {

writer.eol();
writer.append(" /** Private constructor for FetchGroup building */").eol();
writer.append(" private Q%s(Query<%s> fetchGroupQuery) {", shortName, shortName).eol();
writer.append(" private Q%s(io.ebean.Query<%s> fetchGroupQuery) {", shortName, shortName).eol();
writer.append(" super(fetchGroupQuery);").eol();
writer.append(" }").eol();

writer.eol();
writer.append(" /** Private constructor for filterMany */").eol();
writer.append(" private Q%s(ExpressionList<%s> filter) {", shortName, shortName).eol();
writer.append(" private Q%s(io.ebean.ExpressionList<%s> filter) {", shortName, shortName).eol();
writer.append(" super(filter);").eol();
writer.append(" }").eol();
}
Expand Down Expand Up @@ -301,8 +292,8 @@ private void writeAssocClass() {

private void writeAssocFilterMany() {
writer.eol();
writer.append(" public final R filterMany(Consumer<Q%s> apply) {", shortName).eol();
writer.append(" final ExpressionList list = Expr.factory().expressionList();", shortName).eol();
writer.append(" public final R filterMany(java.util.function.Consumer<Q%s> apply) {", shortName).eol();
writer.append(" final io.ebean.ExpressionList list = io.ebean.Expr.factory().expressionList();", shortName).eol();
writer.append(" final var qb = new Q%s(list);", shortName).eol();
writer.append(" apply.accept(qb);").eol();
writer.append(" expr().filterMany(_name).addAll(list);").eol();
Expand Down