kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | d456ce00dbfc94468a8f886455cacca1a36722bdf18e7b0f28c4bb8fdebeeef7 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-10-20 10:36 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-10-20 10:44 +02:00 |
| Parents | 2faf4660456e |
4 files changed
modified driver-core/CHANGELOG.rst +2 −0
| @@ -4,6 +4,8 @@ | ||
| 4 | 4 | 2.1.3: |
| 5 | 5 | ------ |
| 6 | 6 | |
| 7 | +- [bug] Ignore static fields in mapper (JAVA-510) | |
| 8 | + | |
| 7 | 9 | Merged from 2.0 branch: |
| 8 | 10 | |
| 9 | 11 | - [bug] Handle null pool in PooledConnection.release (JAVA-449) |
modified driver-mapping/src/main/java/com/datastax/driver/mapping/AnnotationParser.java +4 −5
| @@ -16,14 +16,13 @@ | ||
| 16 | 16 | package com.datastax.driver.mapping; |
| 17 | 17 | |
| 18 | 18 | import java.lang.annotation.Annotation; |
| 19 | +import java.lang.reflect.*; | |
| 19 | 20 | import java.lang.reflect.Field; |
| 20 | -import java.lang.reflect.Method; | |
| 21 | -import java.lang.reflect.ParameterizedType; | |
| 22 | -import java.lang.reflect.Type; | |
| 23 | 21 | import java.util.*; |
| 24 | 22 | |
| 25 | 23 | import com.google.common.collect.ImmutableSet.Builder; |
| 26 | 24 | import com.google.common.collect.ImmutableSet; |
| 25 | + | |
| 27 | 26 | import com.datastax.driver.mapping.annotations.Frozen; |
| 28 | 27 | |
| 29 | 28 | import com.datastax.driver.core.ConsistencyLevel; |
| @@ -71,7 +70,7 @@ | ||
| 71 | 70 | List<Field> rgs = new ArrayList<Field>(); |
| 72 | 71 | |
| 73 | 72 | for (Field field : entityClass.getDeclaredFields()) { |
| 74 | - if(field.isSynthetic()) | |
| 73 | + if(field.isSynthetic() || (field.getModifiers() & Modifier.STATIC) == Modifier.STATIC) | |
| 75 | 74 | continue; |
| 76 | 75 | |
| 77 | 76 | AnnotationChecks.validateAnnotations(field, "entity", |
| @@ -121,7 +120,7 @@ | ||
| 121 | 120 | List<Field> columns = new ArrayList<Field>(); |
| 122 | 121 | |
| 123 | 122 | for (Field field : udtClass.getDeclaredFields()) { |
| 124 | - if(field.isSynthetic()) | |
| 123 | + if(field.isSynthetic() || (field.getModifiers() & Modifier.STATIC) == Modifier.STATIC) | |
| 125 | 124 | continue; |
| 126 | 125 | |
| 127 | 126 | AnnotationChecks.validateAnnotations(field, "UDT", |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperTest.java +3 −0
| @@ -57,6 +57,9 @@ | ||
| 57 | 57 | writeConsistency="QUORUM") |
| 58 | 58 | public static class User { |
| 59 | 59 | |
| 60 | + // Dummy constant to test that static fields are properly ignored | |
| 61 | + public static final int FOO = 1; | |
| 62 | + | |
| 60 | 63 | public enum Gender { FEMALE, MALE } |
| 61 | 64 | |
| 62 | 65 | @PartitionKey |
modified driver-mapping/src/test/java/com/datastax/driver/mapping/MapperUDTTest.java +4 −0
| @@ -121,6 +121,10 @@ | ||
| 121 | 121 | |
| 122 | 122 | @UDT(keyspace = "ks", name = "address") |
| 123 | 123 | public static class Address { |
| 124 | + | |
| 125 | + // Dummy constant to test that static fields are properly ignored | |
| 126 | + public static final int FOO = 1; | |
| 127 | + | |
| 124 | 128 | private String street; |
| 125 | 129 | |
| 126 | 130 | private String city; |