Skip to content

Commit b0bff85

Browse files
authored
Bypass unnecessary getByCode query
For `languageService` used in https://github.com/shopizer-ecommerce/shopizer/blob/master/sm-shop/src/main/java/com/salesmanager/shop/populator/customer/CustomerPopulator.java#L232, if language code is not available(==null), it is guaranteed nothing will be retrieved since column `code` in table `LANGUAGE` is not null. In such case, the query can be bypassed and saves one network round-trip.
1 parent 1facdf1 commit b0bff85

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sm-shop/src/main/java/com/salesmanager/shop/populator/customer/CustomerPopulator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ public Customer populate(PersistableCustomer source, Customer target,
229229
}
230230

231231
if(target.getDefaultLanguage()==null) {
232-
Language lang = languageService.getByCode(source.getLanguage());
232+
Language lang = source.getLanguage() == null ?
233+
null : languageService.getByCode(source.getLanguage());
234+
233235
if(lang==null) {
234236
lang = store.getDefaultLanguage();
235237
}

0 commit comments

Comments
 (0)