Package org.nutz.trans

Examples of org.nutz.trans.Atom


    assertTrue(null != dao.fetch(Pet.class, 1));
    assertTrue(null != dao.fetch(Pet.class, 2));
    assertTrue(null != dao.fetch(Pet.class, 3));

    FieldFilter.create(Pet.class, "name|id").run(new Atom() {
      public void run() {
        assertTrue(null != dao.fetch(Pet.class));
      }
    });
  }
View Full Code Here


    pojos.dropPlatoon(p.getId());
  }

  @Test
  public void fetch_null_field_links() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Platoon p = dao.fetchLinks(dao.fetch(Platoon.class), "tanks|soliders");
        assertEquals(2, p.getTanks().size());
        assertEquals(5, p.getSoliders().size());
      }
View Full Code Here

    });
  }

  @Test
  public void delete_links() {
    TableName.run(platoon, new Atom() {
      public void run() {
        Soldier s = dao.fetchLinks(dao.fetch(Soldier.class, "ZZH"), "guns");
        assertEquals(3, s.getGuns().length);
        dao.deleteLinks(s, "guns");
        assertEquals(8, dao.count(Gun.class));
View Full Code Here

  public Platoon create4Platoon(Base base, String name) {
    final Platoon p = dao().insert(Platoon.make(base, name));
    int id = p.getId();
    initPlatoon(id);
    TableName.run(id, new Atom() {
      public void run() {
        Soldier mick = Soldier.make("Mick");
        Soldier zzh = Soldier.make("ZZH");
        Soldier peter = Soldier.make("Peter");
        Soldier sm = Soldier.make("Super Man");
View Full Code Here

          method);
      NutTestContext.me().initIoc();

      if (needRollback)
        try {
          Trans.exec(new Atom() {
            @Override
            public void run() {
              NutTestClassMethodsRunner.super.invokeTestMethod(
                  method, notifier);
              throw JustRollback.me();// 这样,无论原方法是否跑异常,事务模板都能收到异常,并回滚
View Full Code Here

      // 处理事务回滚问题
      final boolean needRollback = NutTestContext.me().needRollback(
          fTestMethod.getMethod());
      if (needRollback)
        try {
          Trans.exec(new Atom() {
            @Override
            public void run() {
              try {
                fTestMethod.invokeExplosively(fTarget);
              } catch (Throwable e) {
View Full Code Here

    public TransactionInterceptor(int level) {
        this.level = level;
    }

    public void filter(final InterceptorChain chain) {
        Trans.exec(level, new Atom() {
            public void run() {
                try {
                    chain.doChain();
                }
                catch (Throwable e) {
View Full Code Here

        pojos.dropPlatoon(p.getId());
    }

    @Test
    public void fetch_links() {
        TableName.run(platoon, new Atom() {
            public void run() {
                Platoon p = dao.fetchLinks(dao.fetch(Platoon.class), "leader");
                assertEquals("ZZH", p.getLeaderName());
                assertEquals("ZZH", p.getLeader().getName());
            }
View Full Code Here

        });
    }

    @Test
    public void delete_links() {
        TableName.run(platoon, new Atom() {
            public void run() {
                Tank t = dao.fetchLinks(dao.fetch(Tank.class, "M1-A1"), "motorman");
                dao.deleteLinks(t, "motorman");
                assertEquals(4, dao.count(Soldier.class));
                assertEquals(2, dao.count(Tank.class));
View Full Code Here

        });
    }

    @Test
    public void delete_with() {
        TableName.run(platoon, new Atom() {
            public void run() {
                Tank t = dao.fetchLinks(dao.fetch(Tank.class, "M1-A1"), "motorman");
                dao.deleteWith(t, "motorman");
                assertEquals(4, dao.count(Soldier.class));
                assertEquals(1, dao.count(Tank.class));
View Full Code Here

TOP

Related Classes of org.nutz.trans.Atom

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.