Skip to content

Commit

Permalink
Fix for feliperazeek#37 (do not index @transient fields)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgooren committed Dec 5, 2011
1 parent 4199cf1 commit 7da9afb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/play/modules/elasticsearch/mapping/impl/PlayModelMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Transient;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand Down Expand Up @@ -50,7 +52,19 @@ public PlayModelMapper(Class<M> clazz) {
static boolean shouldIgnoreField(Field field) {
String name = field.getName();

return StringUtils.isBlank(name) || IGNORE_FIELDS.contains(name);
return StringUtils.isBlank(name) || IGNORE_FIELDS.contains(name)
|| shouldIgnoreJPAField(field);
}

/**
* Checks if a field should be ignored based on JPA-specifics
*
* @param field
* the field to check
* @return true if the field should be ignored, false otherwise
*/
static boolean shouldIgnoreJPAField(Field field) {
return field.isAnnotationPresent(Transient.class);
}

static boolean userRequestedIgnoreField(Field field) {
Expand Down

0 comments on commit 7da9afb

Please sign in to comment.