public void doEvent(JFishEvent event) {
    Object entity = event.getObject();
    JFishInsertOrUpdateEvent insertOrUpdate = (JFishInsertOrUpdateEvent) event;

    int updateCount = 0;
    if (LangUtils.isMultiple(entity)) {
      Collection<Object> entities = CUtils.toCollection(entity);
      for (Object obj : entities) {
        if (obj == null) continue;
        throwIfMultiple(entities, obj);
        updateCount += this.onInnerEventWithSingle(obj, insertOrUpdate);
      }
    } else {
      updateCount = onInnerEventWithSingle(entity, insertOrUpdate);
    }
    event.setUpdateCount(updateCount);
  }
Example #2
0
  @Test
  public void testPersonList() {
    TestPerson hh = new TestPerson();
    hh.setUserName("hanhan");
    hh.setAge(30);

    TestPerson parent = new TestPerson();
    parent.setUserName("hanrenjun");
    parent.setAge(60);

    hh.setParent(parent);

    Collection<TestPerson> lists = CUtils.newHashSet();
    lists.add(hh);

    String xmlStr = XmlUtils.toXML(lists, "personlist", Set.class, "person", TestPerson.class);

    System.out.println("testPersonList xml:\n " + xmlStr);

    Collection<TestPerson> list =
        XmlUtils.toBean(xmlStr, "personlist", List.class, "person", TestPerson.class);
    Assert.assertEquals(hh.getUserName(), list.iterator().next().getUserName());
  }