In version 13.22 if the entity definition is in a different package, the generated query bean cannot resolve the symbol erro

This commit is contained in:
Rob Bygrave
2023-10-09 21:10:56 +13:00
parent 716b7e7b93
commit 395edb62bf
4 changed files with 39 additions and 3 deletions
@@ -0,0 +1,18 @@
package org.example.domain;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import org.example.domain.other.OtherBean;
@SuppressWarnings("unused")
@Entity
public class OtherMain {
@Id
long id;
@ManyToOne
OtherBean other;
}
@@ -0,0 +1,13 @@
package org.example.domain.other;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@SuppressWarnings("unused")
@Entity
public class OtherBean {
@Id
long id;
String name;
}
@@ -362,7 +362,8 @@ class ProcessingContext implements Constants {
private PropertyType createPropertyTypeAssoc(String fullName) {
String[] split = Split.split(fullName);
String propertyName = "Q" + split[1] + ".Assoc";
return new PropertyTypeAssoc(propertyName);
String importName = split[0] + ".query.Q" + split[1];
return new PropertyTypeAssoc(propertyName, importName);
}
/**
@@ -7,13 +7,17 @@ import java.util.Set;
*/
class PropertyTypeAssoc extends PropertyType {
private final String importName;
/**
* Construct given the associated bean type name and package.
*
* @param qAssocTypeName the associated bean type name.
* @param importName the import for the Assoc bean.
*/
PropertyTypeAssoc(String qAssocTypeName) {
PropertyTypeAssoc(String qAssocTypeName, String importName) {
super(qAssocTypeName);
this.importName = importName;
}
/**
@@ -21,7 +25,7 @@ class PropertyTypeAssoc extends PropertyType {
*/
@Override
void addImports(Set<String> allImports) {
// do nothing
allImports.add(importName);
}
}