diff --git a/ebean-querybean/src/test/java/org/example/domain/other/OtherSiteUser.java b/ebean-querybean/src/test/java/org/example/domain/other/OtherSiteUser.java new file mode 100644 index 0000000000..fe5553462b --- /dev/null +++ b/ebean-querybean/src/test/java/org/example/domain/other/OtherSiteUser.java @@ -0,0 +1,47 @@ +package org.example.domain.other; + +import jakarta.persistence.*; + +import java.util.Objects; +import java.util.UUID; + +@SuppressWarnings("unused") +@Entity +public class OtherSiteUser { + + @Embeddable + public static class Id { + + // Use siteId, userId matching by db column naming convention + public UUID siteId; + public UUID userId; + + public Id(UUID siteId, UUID userId) { + this.siteId = siteId; + this.userId = userId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Id that = (Id) o; + return Objects.equals(siteId, that.siteId) && Objects.equals(userId, that.userId); + } + + @Override + public int hashCode() { + return Objects.hash(siteId, userId); + } + } + + @EmbeddedId + Id id; + + String description; + + @Version + long version; + + } diff --git a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java index 28a9b537e3..149fe62ecc 100644 --- a/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java +++ b/querybean-generator/src/main/java/io/ebean/querybean/generator/ProcessingContext.java @@ -80,7 +80,7 @@ class ProcessingContext implements Constants { /** * For partial compile the previous list of prefixed entity classes. */ - private List loadedPrefixEntities = new ArrayList<>(); + private final List loadedPrefixEntities = new ArrayList<>(); /** * The package for the generated EntityClassRegister. @@ -360,7 +360,15 @@ private static Object readTargetEntityFromAnnotation(AnnotationMirror mirror) { * Create the QAssoc PropertyType. */ private PropertyType createPropertyTypeAssoc(String fullName) { - String[] split = Split.split(fullName); + TypeElement typeElement = elementUtils.getTypeElement(fullName); + String type; + if (typeElement.getNestingKind().isNested()) { + type = typeElement.getEnclosingElement().toString() + "$" + typeElement.getSimpleName(); + } else { + type = typeElement.getQualifiedName().toString(); + } + + String[] split = Split.split(type); String propertyName = "Q" + split[1] + ".Assoc"; String importName = split[0] + ".query.Q" + split[1]; return new PropertyTypeAssoc(propertyName, importName);