Skip to content

Commit

Permalink
Merge pull request #3237 from ebean-orm/feature/3233
Browse files Browse the repository at this point in the history
#3234 - Query Bean Generator Generates Non-Compilable Code When Entit…
  • Loading branch information
rbygrave authored Oct 9, 2023
2 parents 7d1774e + b3a577e commit 32188bd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ProcessingContext implements Constants {
/**
* For partial compile the previous list of prefixed entity classes.
*/
private List<String> loadedPrefixEntities = new ArrayList<>();
private final List<String> loadedPrefixEntities = new ArrayList<>();

/**
* The package for the generated EntityClassRegister.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 32188bd

Please sign in to comment.