GettingStarted-Sajori.NET-with-Spring.NET - xpenguin.biz

namibiancurrishInternet and Web Development

Nov 12, 2013 (3 years and 7 months ago)

87 views

Getting Started

Sajori.NET

with Spring.NET


2007/10

yuichi TAKAHASHI

Copyright 2007 yuichi TAKAHASHI

2

プロジェクトの作成

Copyright 2007 yuichi TAKAHASHI

3

参照の設定

Copyright 2007 yuichi TAKAHASHI

4

クラスの定義


[TestFixture]


public class Class1 : TransactionalTestCaseWithSpring


{


[Test]


public void HelloSajori()


{


ISampleDao dao = (ISampleDao)this.context.GetObject("SampleDao");


Assert.IsNotNull(dao);


this.CreateTables(dao, typeof(SampleEntity));


SampleEntity se = new SampleEntity();


se.keyString = "00001";


se.valueString = "this is test.";


dao.Save(se);


SampleEntity se2 = (SampleEntity)dao.Find(se);


Assert.AreEqual(se.keyString, se2.keyString);


Assert.AreEqual(se.valueString, se2.valueString);


}


}



public interface ISampleDao : ISajoriAdoDaoSupport{}



public class SampleDao : SajoriAdoDaoSupport, ISampleDao{}



[Mapping]


public class SampleEntity


{


[Mapping(UniqueKey = true)]


public String keyString;



[Mapping]


public String valueString;


}

Copyright 2007 yuichi TAKAHASHI

5

設定ファイルの作成

Copyright 2007 yuichi TAKAHASHI

6

<?xml version="1.0" encoding="utf
-
8" ?>

<configuration>



<configSections>


<sectionGroup name="spring">


<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>


<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />


<section name="parsers" type="Spring.Context.Support.ConfigParsersSectionHandler, Spring.Core" />


</sectionGroup>


</configSections>



<spring>


<parsers>


<parser type="Spring.Data.DatabaseConfigParser, Spring.Data" />


</parsers>


<context>


<resource uri="config://spring/objects"/>


</context>


<objects xmlns="http://www.springframework.net" xmlns:db="http://www.springframework.net/database">



<object name="appConfigPropertyHolder" type="Xpenguin.Sajori.Spring.ExtendedPropertyPlaceholderConfigurer, Sajori.Spring">


<property name="VariableSources" value="ConnectionStringsVariableSource"/>


</object>




<db:dbProvider id="DbProvider" provider="${TEST.providerName}" connectionString="${TEST.connectionString}"/>



<object id="TransactionManager" type="Spring.Data.AdoPlatformTransactionManager, Spring.Data">


<property name="DbProvider" ref="DbProvider"/>


</object>




<object id="baseDao" abstract="true">


<property name="DbProvider" ref="DbProvider"/>


</object>




<object id="SampleDao" type="ModelTestWithSpring.SampleDao" parent="baseDao"/>




</objects>


</spring>



<connectionStrings>


<add name="TEST" connectionString="Data Source=(local);Initial Catalog=test_db;Integrated Security=True;Pooling=False"/>


</connectionStrings>



</configuration>

Copyright 2007 yuichi TAKAHASHI

7

NUnit
で実行

Copyright 2007 yuichi TAKAHASHI

8

About Sajori.NET


Official Site


http://xpenguin.biz/sajori/


Sample source code is also available.


License


Apache License, Version 2.0


http://www.apache.org/licenses/LICENSE
-
2.0


Technical Supports (fare
-
paying)


foreach ltd. (info@4each.biz)


03
-
5246
-
5741