Exemple #1
0
 @Test
 public void testUpdate() {
   Person person = randomPerson();
   data.insert(person);
   assertTrue(person.getId() > 0);
   person.setName("Bob Smith");
   Calendar calendar = Calendar.getInstance();
   calendar.set(1983, Calendar.NOVEMBER, 11);
   person.setBirthday(calendar.getTime());
   EntityProxy<Person> proxy = Person.$TYPE.proxyProvider().apply(person);
   int count = 0;
   for (Property ignored :
       proxy.filterProperties(
           new Predicate<Property<Person, ?>>() {
             @Override
             public boolean test(Property value) {
               return value.state() == PropertyState.MODIFIED;
             }
           })) {
     count++;
   }
   assertEquals(2, count);
   data.update(person);
   for (Property ignored :
       proxy.filterProperties(
           new Predicate<Property<Person, ?>>() {
             @Override
             public boolean test(Property value) {
               return value.state() == PropertyState.MODIFIED;
             }
           })) {
     fail();
   }
 }
Exemple #2
0
 private void writeObject(ObjectOutputStream stream) throws IOException {
   stream.defaultWriteObject();
   Type<E> type = SerializationContext.getType(entityClass);
   EntityProxy<E> proxy = type.proxyProvider().apply(entity);
   for (Property<E, ?> property : proxy.filterProperties(getPropertyFilter())) {
     Object value = property.get();
     stream.writeObject(value);
   }
 }
Exemple #3
0
 private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
   stream.defaultReadObject();
   Type<E> type = SerializationContext.getType(entityClass);
   entity = type.factory().get();
   EntityProxy<E> proxy = type.proxyProvider().apply(entity);
   for (Property<E, ?> property : proxy.filterProperties(getPropertyFilter())) {
     Object value = stream.readObject();
     property.setObject(value, PropertyState.LOADED);
   }
 }