diff options
author | kmoore | 2012-04-18 16:49:20 +0000 |
---|---|---|
committer | kmoore | 2012-04-18 16:49:20 +0000 |
commit | b51f6e51daced8d60d673a5f0c1d811fdd62402e (patch) | |
tree | ad1a9e7b0a857ce0060a539362d05bb54ac13099 | |
parent | 1b44abe79ab5778ca5941afc525ec2000d0dba9e (diff) | |
download | webtools.dali-b51f6e51daced8d60d673a5f0c1d811fdd62402e.tar.gz webtools.dali-b51f6e51daced8d60d673a5f0c1d811fdd62402e.tar.xz webtools.dali-b51f6e51daced8d60d673a5f0c1d811fdd62402e.zip |
minor performance tweaks for updating descendants and validating tables
2 files changed, 38 insertions, 6 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java index d5e99192ab..70b9f653b4 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java @@ -316,6 +316,9 @@ public abstract class AbstractJavaEntity } protected Iterable<Entity> buildDescendants() { + if (!isRootEntity()) { + return EmptyIterable.instance(); + } return new FilteringIterable<Entity>(this.getPersistenceUnit().getEntities()) { @Override protected boolean accept(Entity entity) { @@ -1020,7 +1023,15 @@ public abstract class AbstractJavaEntity protected boolean tableNameIsValid_(String tableName) { return this.connectionProfileIsActive() ? (this.resolveDbTable(tableName) != null) : - CollectionTools.contains(this.getAllAssociatedTableNames(), tableName); + this.tableNameIsAssociatedTable(tableName); + } + + protected boolean tableNameIsAssociatedTable(String tableName) { + //short-circuit for performance during validation, likely that the table is the primary table + if (tableName != null && tableName.equals(this.getPrimaryTableName())) { + return true; + } + return CollectionTools.contains(this.getAllAssociatedTableNames(), tableName); } @@ -1038,8 +1049,13 @@ public abstract class AbstractJavaEntity @Override public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - // matching database objects and identifiers is database platform-specific - return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName); + //short-circuit for performance during validation, no reason to build all the iterables in getallAssociatedDbTables() + //i think the real answer is not to be validating in this case, but i believe that would involve some api changes up in NamedColumnValidator + if (getDataSource().connectionProfileIsActive()) { + // matching database objects and identifiers is database platform-specific + return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName); + } + return null; } /** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java index fc0e6767ba..c2bafa60b0 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java @@ -356,6 +356,9 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> } protected Iterable<Entity> buildDescendants() { + if (!isRootEntity()) { + return EmptyIterable.instance(); + } return new FilteringIterable<Entity>(this.getPersistenceUnit().getEntities()) { @Override protected boolean accept(Entity entity) { @@ -1439,7 +1442,16 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> protected boolean tableNameIsValid_(String tableName) { return this.connectionProfileIsActive() ? (this.resolveDbTable(tableName) != null) : - CollectionTools.contains(this.getAllAssociatedTableNames(), tableName); + this.tableNameIsAssociatedTable(tableName); + } + + protected boolean tableNameIsAssociatedTable(String tableName) { + //short-circuit for performance during validation, likely that the table is the primary table + //i think the real answer is not to be validating in this case, but i believe that would involve some api changes up in NamedColumnValidator + if (tableName != null && tableName.equals(this.getPrimaryTableName())) { + return true; + } + return CollectionTools.contains(this.getAllAssociatedTableNames(), tableName); } @@ -1470,8 +1482,12 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> @Override public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) { - // matching database objects and identifiers is database platform-specific - return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName); + //short-circuit for performance during validation, no reason to build all the iterables in getallAssociatedDbTables() + if (getDataSource().connectionProfileIsActive()) { + // matching database objects and identifiers is database platform-specific + return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName); + } + return null; } /** |