Skip to content

Commit 3e1451b

Browse files
committed
Merge branch 'master' of github.com:ebean-orm/ebean
2 parents ee8e489 + 4ac3c4d commit 3e1451b

File tree

6 files changed

+85
-4
lines changed

6 files changed

+85
-4
lines changed

ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,9 @@ public Collection<DeployBeanProperty> propertiesAll() {
804804
* Return the defaultSelectClause using FetchType.LAZY and FetchType.EAGER.
805805
*/
806806
public String getDefaultSelectClause() {
807-
808807
StringBuilder sb = new StringBuilder();
809808

810809
boolean hasLazyFetch = false;
811-
812810
for (DeployBeanProperty prop : propMap.values()) {
813811
if (!prop.isTransient() && !(prop instanceof DeployBeanPropertyAssocMany<?>)) {
814812
if (prop.isFetchEager()) {

ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ public void setAggregation(String aggregation) {
617617
this.dbRead = true;
618618
this.dbInsertable = false;
619619
this.dbUpdateable = false;
620+
// aggregation by default not fetchEager
621+
this.fetchEager = false;
620622
}
621623

622624
/**
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.tests.aggregateformula;
2+
3+
import io.ebean.annotation.Aggregation;
4+
import jakarta.persistence.Column;
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.Id;
7+
import jakarta.persistence.Lob;
8+
9+
@Entity
10+
public class EWithLobAndAgg {
11+
12+
@Id
13+
long id;
14+
15+
@Column
16+
String name;
17+
18+
@Lob
19+
@Column
20+
String description;
21+
22+
@Aggregation("count(*)")
23+
int count;
24+
25+
public long id() {
26+
return id;
27+
}
28+
29+
public EWithLobAndAgg setId(long id) {
30+
this.id = id;
31+
return this;
32+
}
33+
34+
public String name() {
35+
return name;
36+
}
37+
38+
public EWithLobAndAgg setName(String name) {
39+
this.name = name;
40+
return this;
41+
}
42+
43+
public String description() {
44+
return description;
45+
}
46+
47+
public EWithLobAndAgg setDescription(String description) {
48+
this.description = description;
49+
return this;
50+
}
51+
52+
public int count() {
53+
return count;
54+
}
55+
56+
public EWithLobAndAgg setCount(int count) {
57+
this.count = count;
58+
return this;
59+
}
60+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.tests.aggregateformula;
2+
3+
import io.ebean.DB;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.Assertions.assertThat;
7+
8+
class TestEWithLobAndAgg {
9+
10+
@Test
11+
void when_lobAndAgg_expect_neitherLobOrAggSelectedByDefault() {
12+
var query = DB.find(EWithLobAndAgg.class);
13+
14+
query.findList();
15+
var sql = query.getGeneratedSql();
16+
17+
assertThat(sql)
18+
.describedAs("Neither Lob or Aggregation column in query")
19+
.isEqualTo("select t0.id, t0.name from ewith_lob_and_agg t0");
20+
}
21+
}

ebean-test/src/test/java/org/tests/model/aggregation/TestAggregationTopLevel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void query_noSelect() {
2929
.query();
3030

3131
List<DMachineStatsAgg> result = query.findList();
32-
assertThat(sqlOf(query)).contains("select t0.edate, t0.machine_id from d_machine_stats t0 where t0.edate > ?");
32+
assertThat(sqlOf(query)).contains("select t0.machine_id, t0.edate from d_machine_stats t0 where t0.edate > ?");
3333
assertThat(result).isNotEmpty();
3434
}
3535

ebean-test/src/test/java/org/tests/query/aggregation/TestAggregationCount.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testBaseSelect() {
4949
List<TEventOne> list = query.findList();
5050

5151
String sql = sqlOf(query, 5);
52-
assertThat(sql).contains("select t0.id, t0.name, t0.status, t0.version, t0.event_id from tevent_one t0");
52+
assertThat(sql).contains("select t0.id, t0.name, t0.status, t0.event_id, t0.version from tevent_one t0");
5353

5454
for (TEventOne eventOne : list) {
5555
// lazy loading on Aggregation properties

0 commit comments

Comments
 (0)