SlideShare uma empresa Scribd logo
1 de 33
次世代 Dao フレームワーク Doma 2009 年 9 月 12 日 中村年宏 (http://d.hatena.ne.jp/taedium)
自己紹介 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
アジェンダ ,[object Object],[object Object],[object Object],[object Object]
アジェンダ ,[object Object],[object Object],[object Object],[object Object]
Doma とは? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Doma を利用した構成 address dept emp BusinessLogic ( データの利用者 ) AddressDao DepartmentDao EmployeeDao update insert select Doma SQL EMPLOYEE DEPARTMENT ADDRESS emp 、 dept 、 address はエンティティのインスタンス(ドメインの集合) SQL の生成 SQL ファイルの解析 SQL の発行 DB
ドメインの利点 – タイプセーフ public   void  execute( String  orderNo,  String  customerName,      String  phoneNumber,  String  location,  String  description) {      ... } public   void  execute( OrderNo  orderNo,  CustomerName  customerName,      PhoneNumber  phoneNumber,  Location  location,       Description  description) { ... } ドメインを使わない場合(値型を使用する場合) ドメインを使う場合
ドメインの利点 – 振る舞い String phoneNumber =  "03-1234-5678" ; int areaCode =  PhoneNumberUtil.getAreaCode (phoneNumber); PhoneNumber phoneNumber = new PhoneNumber( "03-1234-5678" ); int areaCode =  phoneNumber.getAreaCode (); ドメインを使わない場合(値型を使用する場合) ドメインを使う場合 Employee id phoneNumber ... Department id phoneNumber ... 振る舞いはエンティティにもたせればいいという考え方があるが、エンティティよりもプロパティにもたせた方がコードの重複が少ない。 同じドメインは複数のエンティティにまたがって使われるため。
ドメインの定義 public   class  PhoneNumber  extends  StringDomain<PhoneNumber> { private   static   final   long   serialVersionUID  = 1L; public  PhoneNumber() { } public  PhoneNumber(String value) { super (value); } public   int  getAreaCode() { ... } } 値型に対応する抽象ドメインクラスを継承して作成。 public なデフォルトコンストラクタが必要。 任意のメソッドをもてる。 必要に応じて定義域をバリデーション。
ドメインのインタフェース public   interface  Domain<V, D  extends  Domain<V, D>> { V get(); void  set(V value); void  setDomain(D other); boolean  isNull(); boolean  isChanged(); void  setChanged( boolean  changed); Class<V> getValueClass(); <R, P, TH  extends  Throwable> R accept(DomainVisitor<R, P, TH> visitor, P p) throws  TH, DomaNullPointerException; } PhoneNumber phoneNumber =  new  PhoneNumber(); phoneNumber.set( &quot;03-1234-5678&quot; ); String value = phoneNumber.get(); PhoneNumber copy =  new  PhoneNumber(); copy.setDomain(phoneNumber); 利用例 ジェネリクスを活用しタイプセーフを実現。
エンティティの定義 @Entity public   interface  Employee {      @Id      Identity id();      Name name();      Salary salary();      @Version      VersionNo version(); } ,[object Object],[object Object],[object Object],[object Object],[object Object]
Dao の定義 @Dao (config = AppConfig. class ) public   interface  EmployeeDao {    @Select    Employee selectById(Identity id);    @Select    List<Employee> selectByNames      (List<Name> names);    @Insert    int  insert(Employee employee);    @Update    int  update(Employee employee);    @Delete    int  delete(Employee employee); } ,[object Object],[object Object],[object Object],[object Object],[object Object]
サンプルコード – 追加 Employee employee =  new  Employee_(); employee.id().set(99); employee.name().set( &quot;test&quot; ); employee.salary().set(300); EmployeeDao  dao  =  new  EmployeeDao_(); dao .insert(employee); insert into EMPLOYEE (ID, NAME, SALARY, VERSION) values (99, 'test', 300, 1) Java コード SQL のログ エンティティも Dao も実装クラスを new すれば OK 。
サンプルコード – 検索  &  更新 EmployeeDao  dao  =  new  EmployeeDao_(); Employee employee =  dao .selectById( new  Identity(1)); employee.name().set( &quot;hoge&quot; ); dao .update(employee); select * from employee where id = 1 update EMPLOYEE set NAME = 'hoge', VERSION = 1 + 1 where ID = 1 and VERSION = 1 select * from employee where id =  /*id*/ 0 selectById に対応する SQL ファイル Java コード SQL のログ Dao は実装クラスを new すれば OK 。
アジェンダ ,[object Object],[object Object],[object Object],[object Object]
次世代とは? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
脱黒魔術のためのツール: apt ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
apt の魅力 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Doma における apt の利用 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Doma における apt の利用 – デモ ,[object Object],[object Object],[object Object]
アジェンダ ,[object Object],[object Object],[object Object],[object Object]
Doma の戦略 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
依存ライブラリ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dao ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL ファイル ,[object Object],[object Object],[object Object],[object Object],select * from employee where  /* %if  id != null*/ id =  /*id*/ 99 /* %end */ select * from employee select * from employee where id = ? SQL ファイル 実行される SQL   id != null   が成立する場合 実行される SQL   id != null   が成立しない場合
キャッシュ ,[object Object],[object Object],[object Object],[object Object]
プラガブルな構成 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JavaBeans ( DTO )への変換 public   class  EmployeeDto          implements  java.io.Serializable { private   static   final   long            serialVersionUID  = 1L; private  java.lang.Integer  id ; private  java.lang.String  name ; private  java.lang.Long  salary ; private  java.lang.Integer  versionNo ; // getter/setter @Entity public   interface  Employee { @Id Identity id(); Name name(); Salary salary(); @Version VersionNo versionNo(); } 自動生成 Employee employee = dao.selectById(new Identity(1)); EmployeeDto dto = new EmployeeDto(); CopyUtil. copy (employee, dto); 相互変換 JavaBeans への変換は容易(他のフレームワークとの連携も OK )
アジェンダ ,[object Object],[object Object],[object Object],[object Object]
ロードマップ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
まとめ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]

Mais conteúdo relacionado

Mais procurados

2. ugc net commerce june 2006 question paper
2. ugc net commerce june 2006 question paper2. ugc net commerce june 2006 question paper
2. ugc net commerce june 2006 question paperKumar Nirmal Prasad
 
ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来
ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来
ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来Hiromasa Oka
 
Metadaily80131
Metadaily80131Metadaily80131
Metadaily80131arefnet
 
Soilmechanics1
Soilmechanics1Soilmechanics1
Soilmechanics1guest680a4
 
QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...QNB Group
 
ミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2Qミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2QMaki Fujita
 
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」devsumi2009
 
テキストマイニングとNLPビジネス
テキストマイニングとNLPビジネステキストマイニングとNLPビジネス
テキストマイニングとNLPビジネスHiroshi Ono
 
Table 1
Table 1Table 1
Table 1HITEMY
 
Cloud Computing - クラウドコンピューティング(会津産学懇話会)
Cloud Computing - クラウドコンピューティング(会津産学懇話会)Cloud Computing - クラウドコンピューティング(会津産学懇話会)
Cloud Computing - クラウドコンピューティング(会津産学懇話会)Yusuke Kawasaki
 
كيف تكسب مهارة التركيز
كيف تكسب مهارة التركيزكيف تكسب مهارة التركيز
كيف تكسب مهارة التركيزAhmed Zeen EL Abeden
 
QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...QNB Group
 
Distribution of PHPCon ElePHPant
Distribution of PHPCon ElePHPantDistribution of PHPCon ElePHPant
Distribution of PHPCon ElePHPantNoriko YAMAMOTO
 

Mais procurados (17)

2. ugc net commerce june 2006 question paper
2. ugc net commerce june 2006 question paper2. ugc net commerce june 2006 question paper
2. ugc net commerce june 2006 question paper
 
ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来
ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来
ZOZOTOWNのマルチクラウドへの挑戦と挫折、そして未来
 
Metadaily80131
Metadaily80131Metadaily80131
Metadaily80131
 
Soilmechanics1
Soilmechanics1Soilmechanics1
Soilmechanics1
 
QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 10, 2021 التحليل الفني اليومي لب...
 
ミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2Qミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2Q
 
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
 
D2007p2
D2007p2D2007p2
D2007p2
 
テキストマイニングとNLPビジネス
テキストマイニングとNLPビジネステキストマイニングとNLPビジネス
テキストマイニングとNLPビジネス
 
Table 1
Table 1Table 1
Table 1
 
Cloud Computing - クラウドコンピューティング(会津産学懇話会)
Cloud Computing - クラウドコンピューティング(会津産学懇話会)Cloud Computing - クラウドコンピューティング(会津産学懇話会)
Cloud Computing - クラウドコンピューティング(会津産学懇話会)
 
UGC NET June 2009 PAPER I Solved
UGC NET June 2009 PAPER I SolvedUGC NET June 2009 PAPER I Solved
UGC NET June 2009 PAPER I Solved
 
D2006p2
D2006p2D2006p2
D2006p2
 
كيف تكسب مهارة التركيز
كيف تكسب مهارة التركيزكيف تكسب مهارة التركيز
كيف تكسب مهارة التركيز
 
QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...
QNBFS Daily Technical Trader Qatar - January 18, 2021 التحليل الفني اليومي لب...
 
2004 paper ii
2004 paper ii2004 paper ii
2004 paper ii
 
Distribution of PHPCon ElePHPant
Distribution of PHPCon ElePHPantDistribution of PHPCon ElePHPant
Distribution of PHPCon ElePHPant
 

Semelhante a Sc2009autumn 次世代Daoフレームワーク Doma

Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信Yusuke Kawasaki
 
Identity Technology Trend Overview, February 2009
Identity Technology Trend Overview, February 2009Identity Technology Trend Overview, February 2009
Identity Technology Trend Overview, February 2009Tatsuo Kudo
 
20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説mochiko AsTech
 
20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会Yusuke Ando
 
文献紹介:Semantic-based information retrieval in support of concept design.
文献紹介:Semantic-based information retrieval in support of concept design.文献紹介:Semantic-based information retrieval in support of concept design.
文献紹介:Semantic-based information retrieval in support of concept design.Shin Sano
 
Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()hehe123456
 
技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTracterada
 
Where20 2009report
Where20 2009reportWhere20 2009report
Where20 2009reportToru Mori
 
CSS Nite In Ginza, Vol.36
CSS Nite In Ginza, Vol.36CSS Nite In Ginza, Vol.36
CSS Nite In Ginza, Vol.36Nobuya Sato
 
【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能devsumi2009
 
Search Engines Chapter 1 Summary
Search Engines Chapter 1 SummarySearch Engines Chapter 1 Summary
Search Engines Chapter 1 Summarysleepy_yoshi
 
Open Source Type Pad Mobile
Open Source Type Pad MobileOpen Source Type Pad Mobile
Open Source Type Pad MobileHiroshi Sakai
 
Oracle Unconference 松下 4/22
Oracle Unconference 松下 4/22Oracle Unconference 松下 4/22
Oracle Unconference 松下 4/22matsushita
 
AI&medical imaging in japan 2018
AI&medical imaging in japan 2018AI&medical imaging in japan 2018
AI&medical imaging in japan 2018yoshihiro todoroki
 
081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh PeopleserviceHiroki Itoh
 

Semelhante a Sc2009autumn 次世代Daoフレームワーク Doma (20)

Green IT
Green ITGreen IT
Green IT
 
sigfpai73-kaji
sigfpai73-kajisigfpai73-kaji
sigfpai73-kaji
 
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
Cloud era -『クラウド時代』マッシュアップ技術による地方からの世界発信
 
Identity Technology Trend Overview, February 2009
Identity Technology Trend Overview, February 2009Identity Technology Trend Overview, February 2009
Identity Technology Trend Overview, February 2009
 
20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説20090418 イケテルRails勉強会 第2部Air編 解説
20090418 イケテルRails勉強会 第2部Air編 解説
 
Reloaded
ReloadedReloaded
Reloaded
 
20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会20090612 実践Redmine @ Redmine勉強会
20090612 実践Redmine @ Redmine勉強会
 
文献紹介:Semantic-based information retrieval in support of concept design.
文献紹介:Semantic-based information retrieval in support of concept design.文献紹介:Semantic-based information retrieval in support of concept design.
文献紹介:Semantic-based information retrieval in support of concept design.
 
Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()Cop",!@#%$%&*()*()
Cop",!@#%$%&*()*()
 
技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac技術トレンディセミナー フレームワークとしてのTrac
技術トレンディセミナー フレームワークとしてのTrac
 
Where20 2009report
Where20 2009reportWhere20 2009report
Where20 2009report
 
CSS Nite In Ginza, Vol.36
CSS Nite In Ginza, Vol.36CSS Nite In Ginza, Vol.36
CSS Nite In Ginza, Vol.36
 
【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能【12-B-4】 並列処理開発を支援するコンパイラの機能
【12-B-4】 並列処理開発を支援するコンパイラの機能
 
Search Engines Chapter 1 Summary
Search Engines Chapter 1 SummarySearch Engines Chapter 1 Summary
Search Engines Chapter 1 Summary
 
Open Source Type Pad Mobile
Open Source Type Pad MobileOpen Source Type Pad Mobile
Open Source Type Pad Mobile
 
Oracle Unconference 松下 4/22
Oracle Unconference 松下 4/22Oracle Unconference 松下 4/22
Oracle Unconference 松下 4/22
 
03 Getting Started
03 Getting Started03 Getting Started
03 Getting Started
 
AI&medical imaging in japan 2018
AI&medical imaging in japan 2018AI&medical imaging in japan 2018
AI&medical imaging in japan 2018
 
object-shapes
object-shapesobject-shapes
object-shapes
 
081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice081210 Idcon 04 Itoh Peopleservice
081210 Idcon 04 Itoh Peopleservice
 

Último

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Último (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Sc2009autumn 次世代Daoフレームワーク Doma

  • 1. 次世代 Dao フレームワーク Doma 2009 年 9 月 12 日 中村年宏 (http://d.hatena.ne.jp/taedium)
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Doma を利用した構成 address dept emp BusinessLogic ( データの利用者 ) AddressDao DepartmentDao EmployeeDao update insert select Doma SQL EMPLOYEE DEPARTMENT ADDRESS emp 、 dept 、 address はエンティティのインスタンス(ドメインの集合) SQL の生成 SQL ファイルの解析 SQL の発行 DB
  • 7. ドメインの利点 – タイプセーフ public void execute( String orderNo, String customerName,      String phoneNumber, String location, String description) {      ... } public void execute( OrderNo orderNo, CustomerName customerName,      PhoneNumber phoneNumber, Location location,      Description description) { ... } ドメインを使わない場合(値型を使用する場合) ドメインを使う場合
  • 8. ドメインの利点 – 振る舞い String phoneNumber = &quot;03-1234-5678&quot; ; int areaCode = PhoneNumberUtil.getAreaCode (phoneNumber); PhoneNumber phoneNumber = new PhoneNumber( &quot;03-1234-5678&quot; ); int areaCode = phoneNumber.getAreaCode (); ドメインを使わない場合(値型を使用する場合) ドメインを使う場合 Employee id phoneNumber ... Department id phoneNumber ... 振る舞いはエンティティにもたせればいいという考え方があるが、エンティティよりもプロパティにもたせた方がコードの重複が少ない。 同じドメインは複数のエンティティにまたがって使われるため。
  • 9. ドメインの定義 public class PhoneNumber extends StringDomain<PhoneNumber> { private static final long serialVersionUID = 1L; public PhoneNumber() { } public PhoneNumber(String value) { super (value); } public int getAreaCode() { ... } } 値型に対応する抽象ドメインクラスを継承して作成。 public なデフォルトコンストラクタが必要。 任意のメソッドをもてる。 必要に応じて定義域をバリデーション。
  • 10. ドメインのインタフェース public interface Domain<V, D extends Domain<V, D>> { V get(); void set(V value); void setDomain(D other); boolean isNull(); boolean isChanged(); void setChanged( boolean changed); Class<V> getValueClass(); <R, P, TH extends Throwable> R accept(DomainVisitor<R, P, TH> visitor, P p) throws TH, DomaNullPointerException; } PhoneNumber phoneNumber = new PhoneNumber(); phoneNumber.set( &quot;03-1234-5678&quot; ); String value = phoneNumber.get(); PhoneNumber copy = new PhoneNumber(); copy.setDomain(phoneNumber); 利用例 ジェネリクスを活用しタイプセーフを実現。
  • 11.
  • 12.
  • 13. サンプルコード – 追加 Employee employee = new Employee_(); employee.id().set(99); employee.name().set( &quot;test&quot; ); employee.salary().set(300); EmployeeDao dao = new EmployeeDao_(); dao .insert(employee); insert into EMPLOYEE (ID, NAME, SALARY, VERSION) values (99, 'test', 300, 1) Java コード SQL のログ エンティティも Dao も実装クラスを new すれば OK 。
  • 14. サンプルコード – 検索 & 更新 EmployeeDao dao = new EmployeeDao_(); Employee employee = dao .selectById( new Identity(1)); employee.name().set( &quot;hoge&quot; ); dao .update(employee); select * from employee where id = 1 update EMPLOYEE set NAME = 'hoge', VERSION = 1 + 1 where ID = 1 and VERSION = 1 select * from employee where id = /*id*/ 0 selectById に対応する SQL ファイル Java コード SQL のログ Dao は実装クラスを new すれば OK 。
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. JavaBeans ( DTO )への変換 public class EmployeeDto         implements java.io.Serializable { private static final long          serialVersionUID = 1L; private java.lang.Integer id ; private java.lang.String name ; private java.lang.Long salary ; private java.lang.Integer versionNo ; // getter/setter @Entity public interface Employee { @Id Identity id(); Name name(); Salary salary(); @Version VersionNo versionNo(); } 自動生成 Employee employee = dao.selectById(new Identity(1)); EmployeeDto dto = new EmployeeDto(); CopyUtil. copy (employee, dto); 相互変換 JavaBeans への変換は容易(他のフレームワークとの連携も OK )
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.