コード例 #1
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = null;
     DeleteBase(Base);
     try
     {
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                                     ("Object 1");
         odb.Store(o);
         AssertEquals(1, o.GetId());
     }
     finally
     {
         if (odb != null)
         {
             odb.Close();
         }
     }
 }
コード例 #2
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1()
		{
			if (!isLocal)
			{
				return;
			}
			NeoDatis.Odb.ODB odb = null;
			DeleteBase(Base);
			try
			{
				odb = Open(Base);
				odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId), 
					new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
				NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
					("Object 1");
				odb.Store(o);
				AssertEquals(1, o.GetId());
			}
			finally
			{
				if (odb != null)
				{
					odb.Close();
				}
			}
		}
コード例 #3
0
 /// <exception cref="System.Exception"></exception>
 public virtual void Test1000Objects()
 {
     if (!isLocal)
     {
         return;
     }
     NeoDatis.Odb.ODB odb = null;
     DeleteBase(Base);
     try
     {
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         for (int i = 0; i < 1000; i++)
         {
             NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                                         ("Object " + (i + 1));
             odb.Store(o);
             AssertEquals(i + 1, o.GetId());
         }
         odb.Close();
         odb = Open(Base);
         odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId),
                              new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
         for (int i = 0; i < 1000; i++)
         {
             NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                                         ("Object - bis - " + (i + 1));
             odb.Store(o);
             AssertEquals(1000 + i + 1, o.GetId());
         }
         odb.Close();
     }
     finally
     {
     }
 }
コード例 #4
0
 // nothing
 public override bool BeforeInsert(object @object)
 {
     if (@object.GetType() != typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                     ))
     {
         return(false);
     }
     NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = (NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
                                                              )@object;
     NeoDatis.Tool.Mutex.Mutex mutex = NeoDatis.Tool.Mutex.MutexFactory.Get("auto increment mutex"
                                                                            );
     try
     {
         try
         {
             mutex.Acquire("trigger");
             long id = GetNextId("test");
             o.SetId(id);
             // System.out.println("setting new id "+ id);
             return(true);
         }
         catch (System.Exception e)
         {
             // TODO Auto-generated catch block
             throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
                                                        , e);
         }
     }
     finally
     {
         if (mutex != null)
         {
             mutex.Release("trigger");
         }
     }
 }
コード例 #5
0
		/// <exception cref="System.Exception"></exception>
		public virtual void Test1000Objects()
		{
			if (!isLocal)
			{
				return;
			}
			NeoDatis.Odb.ODB odb = null;
			DeleteBase(Base);
			try
			{
				odb = Open(Base);
				odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId), 
					new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
				for (int i = 0; i < 1000; i++)
				{
					NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
						("Object " + (i + 1));
					odb.Store(o);
					AssertEquals(i + 1, o.GetId());
				}
				odb.Close();
				odb = Open(Base);
				odb.AddInsertTrigger(typeof(NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId), 
					new NeoDatis.Odb.Test.Trigger.LocalAutoIncrementTrigger());
				for (int i = 0; i < 1000; i++)
				{
					NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId o = new NeoDatis.Odb.Test.Trigger.ObjectWithAutoIncrementId
						("Object - bis - " + (i + 1));
					odb.Store(o);
					AssertEquals(1000 + i + 1, o.GetId());
				}
				odb.Close();
			}
			finally
			{
			}
		}