Package org.nutz.trans

Examples of org.nutz.trans.Atom


    public void test_filter_no_field_match() {
        dao.create(EmtryObject.class, true);
        final EmtryObject obj = new EmtryObject();

        // 应该抛出一个DaoException,因为没有任何的字段需要插入!
        FieldFilter.create(EmtryObject.class, "id").run(new Atom() {
            public void run() {
                dao.insert(obj);
            }
        });
View Full Code Here


  @Test
  public void test_c3p0() {
    try {
      // 将两条插入语句包裹在一个事务内执行,第一条可以正常插入,第二条超过字段长度,会抛异常,事务会回滚
      Trans.exec(new Atom() {
        @Override
        public void run() {
          dao_c3p0.insert("msg", Chain.make("message", "abc"));
          dao_c3p0.insert("msg", Chain.make("message", "1234567"));
        }
View Full Code Here

  }

  @Test
  public void test_druid() {
    try {
      Trans.exec(new Atom() {
        @Override
        public void run() {
          dao_druid.insert("msg", Chain.make("message", "abc"));
          dao_druid.insert("msg", Chain.make("message", "1234567"));
        }
View Full Code Here

        doTran2(dao);
    }

    void doTran1(final Dao dao) {
        try {
            Trans.exec(new Atom() {

                @Override
                public void run() {
                    dao.insert("[test]", Chain.make("name", "1"));
                    throw new RuntimeException();
View Full Code Here

        Assert.assertEquals(0, dao.count("[test]"));
    }

    void doTran2(final Dao dao) {
        try {
            Trans.exec(new Atom() {

                @Override
                public void run() {
                    dao.insert("[test]", Chain.make("name", "1"));
                    dao.insert("[test]", Chain.make("name", "111111111111111111111111111111"));
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.