public void CreateUpdateRollback(TestObject to)
 {
     HibernateTemplate.Save(to);
     to.Name = "Updated Name";
     HibernateTemplate.SaveOrUpdate(to);
     throw new Exception("My expected exception for test purposes.");
 }
        public void Create(TestObject to)
        {
            ISession session = null;
            ITransaction transaction = null;
	            
            try
            {
                session = SessionFactory.OpenSession();
                
                transaction = session.BeginTransaction();
	
                session.Save(to);

                transaction.Commit();
            }
            catch
            {
                if(transaction != null)
                    transaction.Rollback(); 
                throw; 
            }
            finally
            {
                if(session != null)
                    session.Close();
            }

        }
Exemple #3
0
        public void Create(TestObject to)
        {
            sessionFactory.GetCurrentSession().FlushMode = FlushMode.Always;
            sessionFactory.GetCurrentSession().Save(to);
            Thread.Sleep(_secondsToSleepBeforeException);

            throw new Exception();
        }
	    public void CreateNative()
	    {
            IApplicationContext ctx;
            string assemblyName = GetType().Assembly.GetName().Name;
            ctx = new XmlApplicationContext("assembly://" + assemblyName + "/Spring.Data.NHibernate/templateTests.xml");

            ITestObjectDao dao = (ITestObjectDao)ctx.GetObject("nativeNHTestObjectDao");
	        
            TestObject toGeorge = new TestObject();
            toGeorge.Name = "George";
            toGeorge.Age = 34;
            dao.Create(toGeorge);

        }
        public void UserCredentialsDbProvider()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoTransProxy"];

            userCredentialsDbProvider.SetCredentialsForCurrentThread("User ID=springqa", "Password=springqa");
            TestObject toGeorge = new TestObject();
            toGeorge.Name = "George";
            toGeorge.Age = 33;
            dao.Create(toGeorge);

            userCredentialsDbProvider.SetCredentialsForCurrentThread("User ID=springqa2", "Password=springqa2");

            TestObject toMary = new TestObject();
            toMary.Name = "Mary";
            toMary.Age = 34;
            dao.Create(toMary);
        }
        public void DemoDao()
        {

            ITestObjectDao dao = (ITestObjectDao)ctx["testObjectDaoViaTxAttributes"];
            TestObject toGeorge = new TestObject();
            toGeorge.Name = "George";
            toGeorge.Age = 33;
            dao.Create(toGeorge);

        }
        private static void ExecuteAndRollbackDaoOperations(ITestObjectDao dao)
        {
            TestObject toBugs = new TestObject();
            toBugs.Name = "Bugs";
            toBugs.Age = 33;
            dao.CreateUpdateRollback(toBugs);

        }
Exemple #8
0
 public void Delete(TestObject to)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
 public void CreateUpdateRollback(TestObject to)
 {
     throw new NotImplementedException();
 }
 public void CreateUpdateRollback(TestObject to)
 {
     throw new NotImplementedException();
 }
Exemple #11
0
 public void DoWork(TestObject testObject)
 {
     testObjectDao.Create(testObject);
 }
 public void CreateUpdateRollback(TestObject to)
 {
     // TODO:  Add NativeNHTestObjectDao.CreateUpdateRollback implementation
 }
 public void Update(TestObject to)
 {
     HibernateTemplate.SaveOrUpdate(to);
 }
Exemple #14
0
	    private static void ExecuteDaoOperations(ITestObjectDao dao)
	    {
	        TestObject toGeorge = new TestObject();
	        toGeorge.Name = "George";
	        toGeorge.Age = 33;
	        dao.Create(toGeorge);
	        TestObject to = dao.FindByName("George");
	        Assert.IsNotNull(to, "FindByName for George should not return null");
	        Assert.AreEqual("George", to.Name);
	        Assert.AreEqual(33, to.Age);
    
	        to.Age=34;
	        dao.Update(to);
    
	        TestObject to2 = dao.FindByName("George");
	        Assert.AreEqual(34, to2.Age);
    
	        dao.Delete(to);
    
	        TestObject to3 = dao.FindByName("George");
	        Assert.IsNull(to3, "Should not have found TestObject with name George. TestObject = " + to.ToString()   );
	    }
        private void zzzExecuteDaoOperations()
        {
            ITestObjectDao dao = (ITestObjectDao)ctx["SimpleTestDao"];

            TestObject toGeorge = new TestObject();
            toGeorge.Name = "George";
            toGeorge.Age = 33;
            dao.Create(toGeorge);
        }
 public void Delete(TestObject to)
 {
     HibernateTemplate.Delete(to);
 }
 public void Update(TestObject to)
 {
     HibernateTemplate.Update(to);
 }
 public void Create(TestObject to)
 {
     //HibernateTemplate.Save(to);
 }
 public void Delete(TestObject to)
 {
     // TODO:  Add NativeNHTestObjectDao.Delete implementation
 }
 public void Update(TestObject to)
 {
     // TODO:  Add NativeNHTestObjectDao.Update implementation
 }
        private void DoSave(bool simulateException)
        {
            using (TransactionScope tx = new TransactionScope())
            {
                ISession s = ((ISessionFactory)ctx["SessionFactory"]).OpenSession();

                TestObject to = new TestObject();
                to.Name = "George";
                to.Age = 33;

                if (simulateException) { throw new Exception("Simulated Failure in Save Operation."); }

                s.Save(to);

                tx.Complete();
            }

        }
 public void CreateUpdateRollback(TestObject to)
 {
     // TODO:  Add NativeNHTestObjectDao.CreateUpdateRollback implementation
 }
 public void Create(TestObject to)
 {
     HibernateTemplate.Save(to);
 }
 public void Update(TestObject to)
 {
     // TODO:  Add NativeNHTestObjectDao.Update implementation
 }
 public void Delete(TestObject to)
 {
     HibernateTemplate.Delete(to);
 }
 public void Delete(TestObject to)
 {
     // TODO:  Add NativeNHTestObjectDao.Delete implementation
 }
Exemple #27
0
 public void DoWork(TestObject testObject)
 {
     testObjectDao.Create(testObject);
 }
 public void Delete(TestObject to)
 {
     throw new NotImplementedException();
 }