From 7753b9b4464e5214618d6342ca44a61fffa44faf Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 22 Feb 2011 21:42:49 +0100 Subject: [PATCH] =?UTF-8?q?DATAJPA-28=20-=20Changed=20invocation=20order?= =?UTF-8?q?=20of=20createIsNewStrategy(=E2=80=A6).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lazily initializing the IsNewAware on first access now as classes implementing the method might wanna delegate to a template method using a constructor parameter. If createIsNewStrategy(…) is called from our constructor already the subclasses additional constructor arguments are not available yet. --- .../data/repository/support/RepositorySupport.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositorySupport.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositorySupport.java index 1def33e85..93ebf69a9 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositorySupport.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/support/RepositorySupport.java @@ -33,7 +33,7 @@ public abstract class RepositorySupport implements Repository { private final Class domainClass; - private final IsNewAware isNewStrategy; + private IsNewAware isNewStrategy; /** @@ -45,8 +45,6 @@ public abstract class RepositorySupport implements Assert.notNull(domainClass); this.domainClass = domainClass; - this.isNewStrategy = createIsNewStrategy(domainClass); - Assert.notNull(isNewStrategy); } @@ -81,6 +79,11 @@ public abstract class RepositorySupport implements */ protected IsNewAware getIsNewStrategy() { + if (isNewStrategy == null) { + this.isNewStrategy = createIsNewStrategy(domainClass); + Assert.notNull(isNewStrategy); + } + return isNewStrategy; } }