public static void Test_CUBRIDCollections_Delete()
    {
      Configuration cfg = (new Configuration()).Configure().AddAssembly(typeof(TestCUBRIDCollectionType).Assembly);
      //Create the database schema
      using (CUBRIDConnection conn = new CUBRIDConnection(cfg.GetProperty(NHibernate.Cfg.Environment.ConnectionString)))
      {
        conn.Open();
        TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
        TestCases.ExecuteSQL("create table TestCUBRIDCollectionType(id int not null auto_increment," +
                             "sequence_column sequence(int), " +
                             "set_column set(int), " +
                             "multiset_column multiset(string)," +
                              "primary key (id))", conn);

        object[] insertSequence = { 0, 1, 2, 3 };
        object[] insertSet = { 4, 5, 6, 7 };
        object[] insertMultiset = { "CUBRID", "qwerty" };
        TestCUBRIDCollectionType testCollections = new TestCUBRIDCollectionType()
        {
          seq = insertSequence,
          set = insertSet,
          multiset = insertMultiset
        };

        //Insert
        ISessionFactory sessionFactory = cfg.BuildSessionFactory();
        using (var session = sessionFactory.OpenSession())
        {
          using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
          {
            session.Save(testCollections);
            trans.Commit();
          }
        }

        //Check the the insert performed correctly
        using (var session = sessionFactory.OpenSession())
        {
          //Retrieve the inserted information
          IQuery queryAfterInsert = session.CreateQuery(" from TestCUBRIDCollectionType");
          IList<TestCUBRIDCollectionType> testQueryAfterInsert = queryAfterInsert.List<TestCUBRIDCollectionType>();

          Debug.Assert(testQueryAfterInsert.Count == 1);
        }

        //Delete the inserted information
        using (var session = sessionFactory.OpenSession())
        {
          using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
          {
            session.Delete(testCollections);
            trans.Commit();
          }
        }

        using (var session = sessionFactory.OpenSession())
        {
          IQuery queryAfterDelete = session.CreateQuery("FROM TestCUBRIDCollectionType");
          IList<TestCUBRIDClobType> testQueryAfterDelete = queryAfterDelete.List<TestCUBRIDClobType>();
          Debug.Assert(testQueryAfterDelete.Count == 0);
        }

        //Clean the database schema
        TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
      }
    }
Esempio n. 2
0
        public static void Test_CUBRIDCollections_Delete()
        {
            Configuration cfg = (new Configuration()).Configure().AddAssembly(typeof(TestCUBRIDCollectionType).Assembly);

            //Create the database schema
            using (CUBRIDConnection conn = new CUBRIDConnection(cfg.GetProperty(NHibernate.Cfg.Environment.ConnectionString)))
            {
                conn.Open();
                TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
                TestCases.ExecuteSQL("create table TestCUBRIDCollectionType(id int not null auto_increment," +
                                     "sequence_column sequence(int), " +
                                     "set_column set(int), " +
                                     "multiset_column multiset(string)," +
                                     "primary key (id))", conn);

                object[] insertSequence = { 0, 1, 2, 3 };
                object[] insertSet      = { 4, 5, 6, 7 };
                object[] insertMultiset = { "CUBRID", "qwerty" };
                TestCUBRIDCollectionType testCollections = new TestCUBRIDCollectionType()
                {
                    seq      = insertSequence,
                    set      = insertSet,
                    multiset = insertMultiset
                };

                //Insert
                ISessionFactory sessionFactory = cfg.BuildSessionFactory();
                using (var session = sessionFactory.OpenSession())
                {
                    using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
                    {
                        session.Save(testCollections);
                        trans.Commit();
                    }
                }

                //Check the the insert performed correctly
                using (var session = sessionFactory.OpenSession())
                {
                    //Retrieve the inserted information
                    IQuery queryAfterInsert = session.CreateQuery(" from TestCUBRIDCollectionType");
                    IList <TestCUBRIDCollectionType> testQueryAfterInsert = queryAfterInsert.List <TestCUBRIDCollectionType>();

                    Debug.Assert(testQueryAfterInsert.Count == 1);
                }

                //Delete the inserted information
                using (var session = sessionFactory.OpenSession())
                {
                    using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
                    {
                        session.Delete(testCollections);
                        trans.Commit();
                    }
                }

                using (var session = sessionFactory.OpenSession())
                {
                    IQuery queryAfterDelete = session.CreateQuery("FROM TestCUBRIDCollectionType");
                    IList <TestCUBRIDClobType> testQueryAfterDelete = queryAfterDelete.List <TestCUBRIDClobType>();
                    Debug.Assert(testQueryAfterDelete.Count == 0);
                }

                //Clean the database schema
                TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
            }
        }
    public static void Test_CUBRIDCollections_Update()
    {
      Configuration cfg = (new Configuration()).Configure().AddAssembly(typeof(TestCUBRIDCollectionType).Assembly);
      //Create the database schema
      using (CUBRIDConnection conn = new CUBRIDConnection(cfg.GetProperty(NHibernate.Cfg.Environment.ConnectionString)))
      {
        conn.Open();
        TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
        TestCases.ExecuteSQL("create table TestCUBRIDCollectionType(id int not null auto_increment," +
                             "sequence_column sequence(int), " +
                             "set_column set(int), " +
                             "multiset_column multiset(string)," +
                              "primary key (id))", conn);

        object[] insertSequence = { 0, 1, 2, 3 };
        object[] insertSet = { 4, 5, 6, 7 };
        object[] insertMultiset = { "CUBRID", "qwerty" };
        TestCUBRIDCollectionType testCollections = new TestCUBRIDCollectionType()
        {
          seq = insertSequence,
          set = insertSet,
          multiset = insertMultiset
        };

        //Insert
        ISessionFactory sessionFactory = cfg.BuildSessionFactory();
        using (var session = sessionFactory.OpenSession())
        {
          using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
          {
            session.Save(testCollections);
            trans.Commit();
          }
        }

        object[] updateSequence = { 10, 11, 12, 13 };
        object[] updateSet = { 14, 15, 16, 17 };
        object[] updateMultiset = {  "ADO.NET", "NHibernate" };
        testCollections.seq = updateSequence;
        testCollections.set = updateSet;
        testCollections.multiset = updateMultiset;

        //Update
        using (var session = sessionFactory.OpenSession())
        {
          using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
          {
            session.Update(testCollections);
            trans.Commit();
          }
        }

        //Check the the insert performed correctly
        using (var session = sessionFactory.OpenSession())
        {
          //Retrieve the inserted information
          IQuery query = session.CreateQuery(" from TestCUBRIDCollectionType");
          IList<TestCUBRIDCollectionType> testQuery = query.List<TestCUBRIDCollectionType>();

          int[] expectedSequence = { 10, 11, 12, 13 };
          int[] expectedSet = { 14, 15, 16, 17 };
          string[] expectedMultiset = { "ADO.NET", "NHibernate" };
          Debug.Assert((int)testQuery[0].id == 1);
          Debug.Assert((int)testQuery[0].seq[0] == expectedSequence[0]);
          Debug.Assert((int)testQuery[0].seq[1] == expectedSequence[1]);
          Debug.Assert((int)testQuery[0].seq[2] == expectedSequence[2]);
          Debug.Assert((int)testQuery[0].seq[3] == expectedSequence[3]);
          Debug.Assert((int)testQuery[0].set[0] == expectedSet[0]);
          Debug.Assert((int)testQuery[0].set[1] == expectedSet[1]);
          Debug.Assert((int)testQuery[0].set[2] == expectedSet[2]);
          Debug.Assert((int)testQuery[0].set[3] == expectedSet[3]);
          Debug.Assert((string)testQuery[0].multiset[0] == expectedMultiset[0]);
          Debug.Assert((string)testQuery[0].multiset[1] == expectedMultiset[1]);
        }

        //Clean the database schema
        TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
      }
    }
Esempio n. 4
0
        public static void Test_CUBRIDCollections_Update()
        {
            Configuration cfg = (new Configuration()).Configure().AddAssembly(typeof(TestCUBRIDCollectionType).Assembly);

            //Create the database schema
            using (CUBRIDConnection conn = new CUBRIDConnection(cfg.GetProperty(NHibernate.Cfg.Environment.ConnectionString)))
            {
                conn.Open();
                TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
                TestCases.ExecuteSQL("create table TestCUBRIDCollectionType(id int not null auto_increment," +
                                     "sequence_column sequence(int), " +
                                     "set_column set(int), " +
                                     "multiset_column multiset(string)," +
                                     "primary key (id))", conn);

                object[] insertSequence = { 0, 1, 2, 3 };
                object[] insertSet      = { 4, 5, 6, 7 };
                object[] insertMultiset = { "CUBRID", "qwerty" };
                TestCUBRIDCollectionType testCollections = new TestCUBRIDCollectionType()
                {
                    seq      = insertSequence,
                    set      = insertSet,
                    multiset = insertMultiset
                };

                //Insert
                ISessionFactory sessionFactory = cfg.BuildSessionFactory();
                using (var session = sessionFactory.OpenSession())
                {
                    using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
                    {
                        session.Save(testCollections);
                        trans.Commit();
                    }
                }

                object[] updateSequence = { 10, 11, 12, 13 };
                object[] updateSet      = { 14, 15, 16, 17 };
                object[] updateMultiset = { "ADO.NET", "NHibernate" };
                testCollections.seq      = updateSequence;
                testCollections.set      = updateSet;
                testCollections.multiset = updateMultiset;

                //Update
                using (var session = sessionFactory.OpenSession())
                {
                    using (var trans = session.BeginTransaction(IsolationLevel.ReadUncommitted))
                    {
                        session.Update(testCollections);
                        trans.Commit();
                    }
                }

                //Check the the insert performed correctly
                using (var session = sessionFactory.OpenSession())
                {
                    //Retrieve the inserted information
                    IQuery query = session.CreateQuery(" from TestCUBRIDCollectionType");
                    IList <TestCUBRIDCollectionType> testQuery = query.List <TestCUBRIDCollectionType>();

                    int[]    expectedSequence = { 10, 11, 12, 13 };
                    int[]    expectedSet      = { 14, 15, 16, 17 };
                    string[] expectedMultiset = { "ADO.NET", "NHibernate" };
                    Debug.Assert((int)testQuery[0].id == 1);
                    Debug.Assert((int)testQuery[0].seq[0] == expectedSequence[0]);
                    Debug.Assert((int)testQuery[0].seq[1] == expectedSequence[1]);
                    Debug.Assert((int)testQuery[0].seq[2] == expectedSequence[2]);
                    Debug.Assert((int)testQuery[0].seq[3] == expectedSequence[3]);
                    Debug.Assert((int)testQuery[0].set[0] == expectedSet[0]);
                    Debug.Assert((int)testQuery[0].set[1] == expectedSet[1]);
                    Debug.Assert((int)testQuery[0].set[2] == expectedSet[2]);
                    Debug.Assert((int)testQuery[0].set[3] == expectedSet[3]);
                    Debug.Assert((string)testQuery[0].multiset[0] == expectedMultiset[0]);
                    Debug.Assert((string)testQuery[0].multiset[1] == expectedMultiset[1]);
                }

                //Clean the database schema
                TestCases.ExecuteSQL("drop table if exists TestCUBRIDCollectionType", conn);
            }
        }