Permalink
Browse files

do not set properties if they are not present in the original entity.…

… this helps keep the default values of wrapper types and prevents setting nulls to primitive types
  • Loading branch information...
1 parent 98830fb commit 23806c9ea7386913878b1ea18c47b8ff20efe43d @musketyr musketyr committed Aug 28, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 core/src/main/groovyx/gaelyk/datastore/DatastoreEntityCoercion.java
@@ -87,6 +87,11 @@ private static Object transformValueForStorage(Object value) {
}
private static <E extends DatastoreEntity<?>> void setEntityProperty(Entity en, E dsEntity, String propertyName) {
+ if (!en.hasProperty(propertyName)) {
+ // the property doesn't have the property set so let it blank
+ // this is important for keeping default values
+ return;
+ }
Object value = en.getProperty(propertyName);
if (value instanceof Text) {
value = ((Text) value).getValue();

0 comments on commit 23806c9

Please sign in to comment.