From 2d03421de4193e2970fd8699688cd70fca1ec665 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 28 Mar 2023 18:44:00 +1300 Subject: [PATCH] Use DeployBeanProperty toString() removing getFullBeanName() --- .../server/deploy/BeanDescriptorManager.java | 24 +++++++++---------- .../deploy/meta/DeployBeanProperty.java | 4 ---- .../server/deploy/parse/AnnotationAssoc.java | 2 +- .../deploy/parse/AnnotationAssocManys.java | 5 ++-- .../deploy/parse/AnnotationAssocOnes.java | 8 +++---- .../server/deploy/parse/AnnotationFields.java | 2 +- .../deploy/parse/DeployCreateProperties.java | 2 +- .../server/deploy/parse/DeployUtil.java | 6 ++--- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java index 7778778ad..7e73a5a94 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/BeanDescriptorManager.java @@ -768,7 +768,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy // find a join to that table... DeployBeanPropertyAssocOne assocOne = descriptor.findJoinToTable(tableName); if (assocOne == null) { - String msg = "Error with property " + prop.getFullBeanName() + ". Could not find a Relationship to table " + tableName + String msg = "Error with property " + prop+ ". Could not find a Relationship to table " + tableName + ". Perhaps you could use a @JoinColumn instead."; throw new RuntimeException(msg); } @@ -811,7 +811,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy Class targetType = prop.getTargetType(); DeployBeanInfo info = deployInfoMap.get(targetType); if (info == null) { - throw new PersistenceException("Can not find descriptor [" + targetType + "] for " + prop.getFullBeanName()); + throw new PersistenceException("Can not find descriptor [" + targetType + "] for " + prop); } return info.getDescriptor(); } @@ -874,7 +874,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy } } // multiple options so should specify mappedBy property - String msg = "Error on " + prop.getFullBeanName() + " missing mappedBy."; + String msg = "Error on " + prop + " missing mappedBy."; msg += " There are [" + matchSet.size() + "] possible properties in " + targetDesc; msg += " that this association could be mapped to. Please specify one using "; msg += "the mappedBy attribute on @OneToMany."; @@ -919,7 +919,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy if (!oneToMany.getCascadeInfo().isSave()) { // The property MUST have persist cascading so that inserts work. Class targetType = oneToMany.getTargetType(); - String msg = "Error on " + oneToMany.getFullBeanName() + ". @OneToMany MUST have "; + String msg = "Error on " + oneToMany + ". @OneToMany MUST have "; msg += "Cascade.PERSIST or Cascade.ALL because this is a unidirectional "; msg += "relationship. That is, there is no property of type " + owningType + " on " + targetType; throw new PersistenceException(msg); @@ -983,14 +983,14 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private DeployBeanPropertyAssocOne mappedOneToOne(DeployBeanPropertyAssocOne prop, String mappedBy, DeployBeanDescriptor targetDesc) { DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy); if (mappedProp == null) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property " + targetDesc + "." + mappedBy); + throw new PersistenceException("Error on " + prop + " Can not find mappedBy property " + targetDesc + "." + mappedBy); } if (!(mappedProp instanceof DeployBeanPropertyAssocOne)) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?"); + throw new PersistenceException("Error on " + prop + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?"); } DeployBeanPropertyAssocOne mappedAssocOne = (DeployBeanPropertyAssocOne) mappedProp; if (!mappedAssocOne.isOneToOne()) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?"); + throw new PersistenceException("Error on " + prop + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a OneToOne?"); } return mappedAssocOne; } @@ -1073,10 +1073,10 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private DeployBeanPropertyAssocOne mappedManyToOne(DeployBeanPropertyAssocMany prop, DeployBeanDescriptor targetDesc, String mappedBy) { DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy); if (mappedProp == null) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property " + mappedBy + " in " + targetDesc); + throw new PersistenceException("Error on " + prop + " Can not find mappedBy property " + mappedBy + " in " + targetDesc); } if (!(mappedProp instanceof DeployBeanPropertyAssocOne)) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + mappedBy + " is not a ManyToOne? in " + targetDesc); + throw new PersistenceException("Error on " + prop + ". mappedBy property " + mappedBy + " is not a ManyToOne? in " + targetDesc); } return (DeployBeanPropertyAssocOne) mappedProp; } @@ -1124,15 +1124,15 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy private DeployBeanPropertyAssocMany mappedManyToMany(DeployBeanPropertyAssocMany prop, String mappedBy, DeployBeanDescriptor targetDesc) { DeployBeanProperty mappedProp = targetDesc.getBeanProperty(mappedBy); if (mappedProp == null) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + " Can not find mappedBy property " + mappedBy + " in " + targetDesc); + throw new PersistenceException("Error on " + prop + " Can not find mappedBy property " + mappedBy + " in " + targetDesc); } if (!(mappedProp instanceof DeployBeanPropertyAssocMany)) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a ManyToMany?"); + throw new PersistenceException("Error on " + prop + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a ManyToMany?"); } DeployBeanPropertyAssocMany mappedAssocMany = (DeployBeanPropertyAssocMany) mappedProp; if (!mappedAssocMany.isManyToMany()) { - throw new PersistenceException("Error on " + prop.getFullBeanName() + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a ManyToMany?"); + throw new PersistenceException("Error on " + prop + ". mappedBy property " + targetDesc + "." + mappedBy + " is not a ManyToMany?"); } return mappedAssocMany; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java index e31b76d16..4f927043c 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java @@ -222,10 +222,6 @@ public class DeployBeanProperty { || AnnotationUtil.has(field, WhoCreated.class)); } - public String getFullBeanName() { - return desc.getFullName() + "." + name; - } - public DeployBeanDescriptor getDesc() { return desc; } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java index 191a43c40..0176c31d4 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssoc.java @@ -23,7 +23,7 @@ abstract class AnnotationAssoc extends AnnotationParser { void setBeanTable(DeployBeanPropertyAssoc prop) { BeanTable assoc = getBeanTable(prop); if (assoc == null) { - throw new BeanNotRegisteredException(errorMsgMissingBeanTable(prop.getTargetType(), prop.getFullBeanName())); + throw new BeanNotRegisteredException(errorMsgMissingBeanTable(prop.getTargetType(), prop.toString())); } prop.setBeanTable(assoc); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java index 0d29c3ba4..5bcd077c1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocManys.java @@ -167,7 +167,7 @@ final class AnnotationAssocManys extends AnnotationAssoc { private void checkSelfManyToMany(DeployBeanPropertyAssocMany prop) { if (prop.getTargetType().equals(descriptor.getBeanType())) { - throw new IllegalStateException("@ManyToMany mapping for " + prop.getFullBeanName() + " requires explicit @JoinTable with joinColumns & inverseJoinColumns. Refer issue #2157"); + throw new IllegalStateException("@ManyToMany mapping for " + prop + " requires explicit @JoinTable with joinColumns & inverseJoinColumns. Refer issue #2157"); } } @@ -266,8 +266,7 @@ final class AnnotationAssocManys extends AnnotationAssoc { elementDescriptor.addBeanProperty(valueProp); } - elementDescriptor.setName(prop.getFullBeanName()); - + elementDescriptor.setName(prop.toString()); factory.createUnidirectional(elementDescriptor, prop.getOwningType(), beanTable, prop.getTableJoin()); prop.setElementDescriptor(factory.createElementDescriptor(elementDescriptor, prop.getManyType(), scalar)); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java index 598962fcf..97e3c3c8f 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java @@ -148,7 +148,7 @@ final class AnnotationAssocOnes extends AnnotationAssoc { private void setFromJoinColumn(DeployBeanPropertyAssocOne prop, BeanTable beanTable, JoinColumn joinColumn) { if (beanTable == null) { - throw new IllegalStateException("Looks like a missing @ManyToOne or @OneToOne on property " + prop.getFullBeanName() + " - no related 'BeanTable'"); + throw new IllegalStateException("Looks like a missing @ManyToOne or @OneToOne on property " + prop + " - no related 'BeanTable'"); } prop.getTableJoin().addJoinColumn(util, false, joinColumn, beanTable); if (!joinColumn.updatable()) { @@ -210,15 +210,15 @@ final class AnnotationAssocOnes extends AnnotationAssoc { private void readPrimaryKeyJoin(PrimaryKeyJoinColumn primaryKeyJoin, DeployBeanPropertyAssocOne prop) { if (!prop.isOneToOne()) { - throw new IllegalStateException("Expecting property " + prop.getFullBeanName() + " with PrimaryKeyJoinColumn to be a OneToOne?"); + throw new IllegalStateException("Expecting property " + prop + " with PrimaryKeyJoinColumn to be a OneToOne?"); } prop.setPrimaryKeyJoin(true); if (!primaryKeyJoin.name().isEmpty()) { - CoreLog.internal.log(INFO, "Automatically determining join columns for @PrimaryKeyJoinColumn - ignoring PrimaryKeyJoinColumn.name attribute [{0}] on {1}", primaryKeyJoin.name(), prop.getFullBeanName()); + CoreLog.internal.log(INFO, "Automatically determining join columns for @PrimaryKeyJoinColumn - ignoring PrimaryKeyJoinColumn.name attribute [{0}] on {1}", primaryKeyJoin.name(), prop); } if (!primaryKeyJoin.referencedColumnName().isEmpty()) { - CoreLog.internal.log(INFO, "Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{0}] on {1}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName()); + CoreLog.internal.log(INFO, "Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{0}] on {1}", primaryKeyJoin.referencedColumnName(), prop); } BeanTable baseBeanTable = factory.beanTable(info.getDescriptor().getBeanType()); String localPrimaryKey = baseBeanTable.getIdColumn(); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java index e4a3fca8c..60ef0ddf7 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationFields.java @@ -384,7 +384,7 @@ final class AnnotationFields extends AnnotationParser { } private void setEncryption(DeployBeanProperty prop, boolean dbEncString, int dbLen) { - util.checkEncryptKeyManagerDefined(prop.getFullBeanName()); + util.checkEncryptKeyManagerDefined(prop.toString()); ScalarType st = prop.getScalarType(); if (byte[].class.equals(st.type())) { // Always using Java client encryption rather than DB for encryption diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java index 31e6533f4..5fc138109 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java @@ -83,7 +83,7 @@ public final class DeployCreateProperties { DeployBeanProperty replaced = desc.addBeanProperty(prop); if (replaced != null && !replaced.isTransient()) { - String msg = "Huh??? property " + prop.getFullBeanName() + " being defined twice"; + String msg = "Huh??? property " + prop + " being defined twice"; msg += " but replaced property was not transient? This is not expected?"; CoreLog.log.log(WARNING, msg); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java index 027ecfc4c..ba7937dc6 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java @@ -106,7 +106,7 @@ public final class DeployUtil { prop.setScalarType(scalarType); prop.setDbType(scalarType.jdbcType()); } catch (IllegalStateException e) { - throw new PersistenceException("Error mapping property " + prop.getFullBeanName() + " - " + e.getMessage()); + throw new PersistenceException("Error mapping property " + prop + " - " + e.getMessage()); } } @@ -141,7 +141,7 @@ public final class DeployUtil { if (scalarType != null || property.isTransient()) { return scalarType; } - throw new PersistenceException(property.getFullBeanName() + " has no ScalarType - type " + propType.getName()); + throw new PersistenceException(property + " has no ScalarType - type " + propType.getName()); } catch (IllegalArgumentException e) { if (property.isTransient()) { // expected for transient properties with unknown/non-mapped types @@ -179,7 +179,7 @@ public final class DeployUtil { Class type = prop.getPropertyType(); ScalarType scalarType = typeManager.dbArrayType(type, prop.getGenericType(), prop.isNullable()); if (scalarType == null) { - throw new RuntimeException("No ScalarType for @DbArray type for " + prop.getFullBeanName()); + throw new RuntimeException("No ScalarType for @DbArray type for " + prop); } int dbType = scalarType.jdbcType(); prop.setDbType(dbType);