seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · title: microsoft powerpoint -...

52
Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved. 1 Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference 2007 Spring 2007 Spring 2007 Spring 2007 Spring 2007 Spring 2007 Spring 2007 Spring 2007 Spring Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference Seasar Conference 2007 2007 2007 2007 2007 2007 2007 2007 Spring Spring Spring Spring Spring Spring Spring Spring Seasar Seasar 2.5 2.5 ブルーオーシャン戦略とは

Upload: others

Post on 03-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.1

Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring

Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 2007 2007 2007 2007 2007 2007 2007 SpringSpringSpringSpringSpringSpringSpringSpring

SeasarSeasar 2.52.5

ブルーオーシャン戦略とは

Page 2: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

2Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略とはブルーオーシャン戦略とは

• ブルーオーシャン

–競争の無い未開拓市場• Wii

• レッドオーシャン

–血みどろの戦いが繰り広げられる既存の市場• これまでのゲーム機

Page 3: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

3Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

レッドオーシャンレッドオーシャン

• 特徴

–同じ市場でライバルに差別化しようとする。

–パイの奪い合い。

–すぐに追いつかれるので差別化できない。

Page 4: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

4Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

レッドオーシャンレッドオーシャン

• Java EE(EJB3, JPA, JSF)

–同一の仕様で実装を競い合う。

• 差別化は難しい。

–機能の肥大化

• あらゆる状況に対応しようとして仕様が膨らむ。

• 仕様が膨大なので学習が大変。

• 複雑な仕様を実装する必要があるのでパフォーマンスが出ない。

–ゲーム機と同じ間違い

Page 5: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

5Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャンブルーオーシャン

• ブルーオーシャンを開拓するには– Wiiに学ぶ

• 複雑になりすぎたゲームではなく、

• もっと簡単で覚えやすいゲームを作れないか。

– Seasar2

• 複雑になりすぎたJava EEではなく、

• もっと簡単で覚えやすいフレームワークを作れないか。

Page 6: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

6Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

Without Without JavaEEJavaEE

Without

Java EE

Page 7: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

7Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

• Seasar2のブルーオーシャン戦略

– JavaEEの機能を削る。

• 削る勇気を持つ。

– Seasarのコミュニティで育てた機能をSeasar2本体

に取り込む。

Page 8: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

8Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

• S2Persistence

– S2Dao + DBFluteの仕様をベース

• S2Presentation

– Teeda + S2JSF without JSF

Page 9: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

9Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

Seasar2.5Seasar2.5の構成の構成

• S2Framework

– org.seasar.framework

• S2Extension

– org.seasar.extension

• S2Persistence

– org.seasar.persistence

• S2Presentation

– org.seasar.presentation

Page 10: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

10Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略の三つの柱ブルーオーシャン戦略の三つの柱

• 大胆にソースコードを削る

• 過去の習慣と常識にとらわれない

• 迷いをなくす

Page 11: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

11Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

• publicフィールド対応

– setter, getterメソッド不要。

– フレームワークと自分自身しか触らないフィールドはpublicでかまわない。

– DIのために必要なフィールドはpublicでかまわない。

–テーブルのカラムと一対一で結びついているフィールドはpublicでかまわない。

• 表示のために加工が必要ならConverterで対応する。

Page 12: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

12Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

• インターフェースは基本不要– 1インターフェース1実装なら不要。

–モックは継承して作ればよい。

Page 13: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

13Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

• 必要最小限の登場人物– Page

• HTMLと一対一

– Service

• ユースケースと一対一

– Entity

• テーブルと一対一

Page 14: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

14Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

• ユースケースの粒度

–基本はサブアプリケーションごと

–複数のサブアプリケーションから共通的に使われる機能は共通のユースケースとして抽出する。

Page 15: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

15Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

ブルーオーシャン戦略ブルーオーシャン戦略

方針が明確で誰が

やっても迷わない

Page 16: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

16Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

employeeListemployeeList.html.html

<table>

<tbody p:items=“#{employeeItems}”>

<span id=“hiredate”

p:value=“#{employee.hiredate}”/>

<p:dateTimeConverter

format=“yyyy/MM/dd” for=“hiredate”/>

</tbody>

</table>

Page 17: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

17Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

EmployeeListPageEmployeeListPage.java.java

public EmployeeService employeeService;

public List<Employee> employeeItems;

public Employee employee;

public void prerender() {

employeeItems = employeeService.findAll();

}

Page 18: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

18Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

EmployeeServiceEmployeeService.java.java

public PersistenceManager pm;

public List<Employee> findAll() {

return pm.findAll(Employee.class);

}

Page 19: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

19Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

Employee.javaEmployee.java

public Long id;

@Required @Length(30)

public String empName;

public Timestamp hiredate;

public Integer version;

public Department department;

Page 20: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

20Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

Seasar2.5Seasar2.5のの開発の進め方開発の進め方

• MLでオープンに仕様を話し合う。

– Seasar Specification Request(SSR-xxxxx)

–誰でも仕様作成に参加できる。

• 実装 & ドキュメント & βリリース

–仕様が決まったものから

–優先順位に応じて

–実装 & ドキュメント & βリリース

Page 21: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

21Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

Seasar2.5Seasar2.5のの開発の進め方開発の進め方

• RCリリース

–すべてのSSRがリリースされたらRCのリリース

• 正式リリース

– タイミングを見て

Page 22: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

22Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

Seasar2.5Seasar2.5のの開発環境開発環境

• Maven2が基本

–プロジェクトの生成。

–テーブルからエンティティの生成。

–エンティティからテーブルを更新。

– SQLファイルからDTOを作成。

– Scaffold。

• Maven2の敷居の高さはSeasar2が吸収

– Eclipseからキックできるようにする。

– Eclipseのプラグインとの組み合わせも含めて提供

する。

Page 23: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

23Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

これまでのプロダクトはどうなるのかこれまでのプロダクトはどうなるのか

• Teeda

– 1.1でSeasar2.5に対応。

– S2Presentationのかわりに使うこともできる。

• Kuina-Dao

– 1.1でSeasar2.5に対応。

– S2Persistenceのかわりに使うこともできる。

• Dolteng

– Teeda Plugin, S2Flex2 Pluginに分解。

Page 24: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

24Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

新規新規Eclipse Eclipse PluginPlugin

• Super Agile Plugin

– Scaffold

–サブアプリケーションの追加。• HTMLの格納ディレクトリ。

• Pageの格納パッケージ。

• Serviceの雛形。

Page 25: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

25Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

新規新規Eclipse Eclipse PluginPlugin

• S2Prensentation Plugin

– HTMLの雛形生成。

– HTMLからPageを自動生成。

– HTMLとPageの相互移動。

– HTMLの自動補完とバリデーション

• ValueBinding

#{}

• Validator

<p:lengthValidator maximum=“5”/>

• Converter

<p:dateTimeConverter pattern=“yyyy/MM/dd”/>

Page 26: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

26Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

新規新規Eclipse Eclipse PluginPlugin

• S2Persistence Plugin

–テーブルからエンティティの自動生成。

–エンティティからテーブルの更新。

– SQLファイルからDTOを作成。

Page 27: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

27Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

S2Persistence(S2Persistence(案案))

• Dao不要

–高水準なPersistenceManager API

• ネストしたManyToOne, OneToOneサポート

• OneToManyサポート

• RDBMSを生かすPaging処理

• パフォーマンスの向上–完全なHOT deploy対応。

–データベースのメタデータを使わずデフォルトのルールとアノテーションを使う。

– PreparedStatementをキャッシュする。

Page 28: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

28Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• キーで検索Employee emp = pm.find(Employee.class, 1);

Page 29: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

29Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• =検索

Employee emp = new Employee();

emp.job = JobType.MANAGER;

Department dept = new Department();

dept.departmentName = “RESEARCH”;

emp.department = dept;

List<Employee> employees =

pm.findAll(Employee.class, emp);

Page 30: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

30Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 自動生成されるSQL

select … from employee e join department d

on e.department_id = d.id

where e.job = ‘MANAGER’

and d.departmentName = ‘RESEARCH’

Page 31: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

31Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• >=,<=検索

EmployeeCriteria criteria =

new EmployeeCriteria();

criteria.salary_GE = 1000;

criteria.salary_LE = 3000;

List<Employee> employees =

pm.findAll(Employee.class, criteria);

Page 32: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

32Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 自動生成されるSQL

select … from employee

where salary >= 1000

and salary <= 3000

Page 33: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

33Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• IS NOT NULLやLIKE検索

EmployeeCriteria criteria =

new EmployeeCriteria();

criteria.commission_IS_NOT_NULL = true;

DepartmentCriteria dcriteria =

new DepartmentCriteria();

dcriteria.departmentName_STARTS = “E”;

criteria.departmentCriteria = dcriteria;

List<Employee> employees =

pm.findAll(Employee.class, criteria);

Page 34: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

34Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 自動生成されるSQL

select … from employee e join department d

on e.department_id = d.id

where e.commission is not null

and d.departmentName like ‘E%’

Page 35: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

35Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• Paging検索

EmployeeCriteria criteria =

new EmployeeCriteria();

criteria.offset = 100;

criteria.limit = 10;

List<Employee> employees =

pm.findAll(Employee.class, criteria);

Page 36: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

36Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 自動生成されるSQL

select … from employee

offset 100 limit 10

#PostgreSQLの場合

Page 37: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

37Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• FETCH JOIN(ManyToOne)検索

EmployeeCriteria criteria =

new EmployeeCriteria();

criteria.departmentFetchJoinType =

FetchJoinType.Outer;

List<Employee> employees =

pm.findAll(Employee.class, criteria);

for (Employee e : employees) {

System.out.println(e.department);

}

Page 38: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

38Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 自動生成されるSQL

select e.*, d.* from employee e left outer join

department d on e.department_id = d.id

Page 39: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

39Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• FETCH JOIN(OneToMany)検索

DeparmentCriteria criteria =

new DepartmentCriteria();

criteria.employeesFetchJoinType =

FetchJoinType.INNER;

Department department =

pm.find(Deparment.class, criteria);

for (Employee e : d.employees) {

System.out.println(e);

}

Page 40: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

40Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 自動生成されるSQL

select * from department;

select * from employee

where department_id in (…);

Page 41: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

41Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• NamedQuery

examples/sql/aaa.sql

select …where …hoge = /*hoge*/1

List<EmployeeDto> dtoList =

pm.getNamedQuery(“examples/sql/aaa.sql”)

.setParameter(“hoge”, 2)

.getResultList(EmployeeDto.class);

Page 42: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

42Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• DynamicQuery

StrinbBuilder sb = new StringBuilder();

List<EmployeeDto> list =

pm.createQuery(sb.toString())

.setParameter(“hoge”, 2)

.getResultList(EmployeeDto.class);

Page 43: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

43Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• Query As Map

StrinbBuilder sb = new StringBuilder();

List<Map> list =

pm.createQuery(sb.toString())

.setParameter(“hoge”, 2)

.getResultList(Map.class);

Page 44: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

44Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• INSERT

Employee e = new Employee();

e.employeeName = “SCOTT”;

pm.insert(e);

Page 45: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

45Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 配列INSERT

List<Employee> employees = new

ArrayList<Employee>();

pm.insert(employees);

Page 46: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

46Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• Bulk INSERT

examples/sql/bbb.sql

insert into … select … where hoge = /*hoge*/1

pm.getNamedQuery(“exmples/sql/bbb.sql”)

.setParameter(“hoge”, 2)

.executeUpdate();

Page 47: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

47Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• UPDATE

Employee e = pm.find(Employee.class, 1);

e.employeeName = “SCOTT”;

pm.update(e);

Page 48: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

48Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 配列UPDATE

List<Employee> employees =

pm.findAll(Employee.class);

pm.update(employees);

Page 49: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

49Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• Bulk UPDATE

examples/sql/bbb.sql

update set … where hoge = /*hoge*/1

pm.getNamedQuery(“exmples/sql/bbb.sql”)

.setParameter(“hoge”, 2)

.executeUpdate();

Page 50: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

50Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• DELETE

Employee e = pm.find(Employee.class, 1);

pm.delete(e);

Page 51: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

51Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• 配列DELETE

List<Employee> employees =

pm.findAll(Employee.class);

pm.delete(employees);

Page 52: Seasar 2s2container.seasar.org/ja/seasar2.5.pdf · 2007. 5. 28. · Title: Microsoft PowerPoint - Seasar2.5.ppt Author: li0934 Created Date: 5/28/2007 3:18:53 AM

52Seasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar ConferenceSeasar Conference

2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring2007 Spring Copyright© 2004-2007 The Seasar Foundation and the others. All rights reserved.

PersistenceManagerPersistenceManager API(API(案案))

• Bulk DELETE

examples/sql/bbb.sql

delete from … where hoge = /*hoge*/1

pm.getNamedQuery(“exmples/sql/bbb.sql”)

.setParameter(“hoge”, 2)

.executeUpdate();