DATAJPA-28 - Changed invocation order of createIsNewStrategy(…).
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.
This commit is contained in:
@@ -33,7 +33,7 @@ public abstract class RepositorySupport<T, ID extends Serializable> implements
|
||||
Repository<T, ID> {
|
||||
|
||||
private final Class<T> domainClass;
|
||||
private final IsNewAware isNewStrategy;
|
||||
private IsNewAware isNewStrategy;
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,8 +45,6 @@ public abstract class RepositorySupport<T, ID extends Serializable> implements
|
||||
|
||||
Assert.notNull(domainClass);
|
||||
this.domainClass = domainClass;
|
||||
this.isNewStrategy = createIsNewStrategy(domainClass);
|
||||
Assert.notNull(isNewStrategy);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +79,11 @@ public abstract class RepositorySupport<T, ID extends Serializable> implements
|
||||
*/
|
||||
protected IsNewAware getIsNewStrategy() {
|
||||
|
||||
if (isNewStrategy == null) {
|
||||
this.isNewStrategy = createIsNewStrategy(domainClass);
|
||||
Assert.notNull(isNewStrategy);
|
||||
}
|
||||
|
||||
return isNewStrategy;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user