Files
ebean/ebean-querybean/src/test/java/org/querytest/InheritanceTest.java
T
Rob Bygrave 0bb2f104a4 [QueryBeans] Fix for missing inherited properties when parent only has @DiscriminatorValue
A parent in the Inheritance hierarchy has @DiscriminatorValue but not the @Inheritance annotation. The bug means the inherited properties are not included on the generated query bean.

The fix is to the querybean-generator to pick up inherited properties for this case.
2023-02-28 23:02:19 +13:00

55 lines
1.1 KiB
Java

package org.querytest;
import org.example.domain.ACat;
import org.example.domain.ADog;
import org.example.domain.Animal;
import org.example.domain.query.QACat;
import org.example.domain.query.QASuperCat;
import org.example.domain.query.QAnimal;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
class InheritanceTest {
@Test
void query_setInheritType() {
ACat cat = new ACat("C1");
cat.save();
ACat cat2 = new ACat("C2");
cat2.save();
ADog dog = new ADog("D1", "D878");
dog.save();
List<Animal> animals = new QAnimal()
.id.greaterOrEqualTo(1L)
.setInheritType(ACat.class)
.findList();
assertThat(animals).isNotEmpty();
}
@Test
void query_onInheritedProperty() {
new QACat()
.name.eq("foo")
.catProp.eq("foo")
.findList();
}
@Test
void query_onInheritedProperty_whenParentOnlyHasDiscriminator() {
// the .name and .catProp properties exist on QASuperCat()
new QASuperCat()
.superCat.eq("foo")
.name.eq("foo")
.catProp.eq("foo")
.findList();
}
}