11==================
2- Daoインタフェース
2+ Dao interfaces
33==================
44
5- .. contents :: 目次
5+ .. contents :: Contents
66 :depth: 3
77
8- Data Access Object ( Dao) はデータベースアクセスのためのインタフェースです。
8+ Data Access Object ( Dao) is interface for access to database.
99
10- Dao定義
10+ Dao definition
1111==================
1212
13- Daoは ``@Dao `` が注釈されたインタフェースとして定義します。
13+ Dao is defined as interface annotated ``@Dao ``.
1414
15- インタフェースの実装クラスはaptによりコンパイル時に自動生成されます。
15+ Class implemented dao interface is generated in compile time by apt.
1616
17- クエリ定義
17+ Query definition
1818==================
1919
20- アノテーションを使って :doc: `query/index ` を定義できます。
20+ :doc: `query/index ` can be defined using annotation.
2121
22- Javaコードで任意のクエリを組み立てるには ` デフォルトメソッド `_ の中で :doc: `query-builder/index ` を使用してください。
22+ You use :doc: `query-builder/index ` in ` default method `_ if you want to build query freely in Java code.
2323
2424.. _dao-default-method :
2525
26- デフォルトメソッド
26+ Default method
2727==================
2828
29- デフォルトメソッドでは任意の処理を記述できます。
29+ You can write java code freely in default method.
30+
31+ You can get ``Config `` instance associated dao instance if you call ``Config.get `` with argument dao instance.
3032
31- ``Config.get `` にDaoのインスタンスを渡すとDaoに関連づけられた ``Config `` インスタンスを取得できます。
3233
3334.. code-block :: java
3435
@@ -43,40 +44,40 @@ Javaコードで任意のクエリを組み立てるには `デフォルトメ
4344 }
4445 }
4546
46- 利用例
47+ Example
4748==================
4849
49- コンパイルすると注釈処理により実装クラスが生成されます。
50- 実装クラスをインスタンス化して使用してください。
51- ただし、設定クラスをDIコンテナで管理する場合、インスタンス化はDIコンテナで制御してください。
50+ Implementation class is generated by annotation processor on compile.
51+ Implementation class is instantiated and used.
52+ But if configuration class is managed by DI container then it should be controlled to instantiate implementation class by DI container.
5253
5354.. code-block :: java
5455
5556 EmployeeDao employeeDao = new EmployeeDaoImpl ();
5657 Employee employee = employeeDao. selectById(1 );
5758
58- デフォルトでは、実装クラスの名前はインタフェースの名前に ``Impl `` をサフィックスしたものになります。
59- パッケージやサフィックスを変更するには :doc: `annotation-processing ` を参照してください。
59+ In default, implementation class name is interface name suffixed with ``Impl ``.
60+ Please refer :doc: `annotation-processing ` to change package and suffix.
6061
61- デフォルトコンストラクタを使用した場合は、 `` @Dao `` の ``config `` 要素に指定した設定により `` DataSource `` が決定されますが、
62- 特定の ``DataSource `` を指定してインスタンス化することも可能です。
62+ If you use default constructor then `` DataSource `` is determined by configuration in ``config `` element of `` @Dao ``.
63+ But it can instantiate with ``DataSource `` specified explicitly.
6364
6465.. code-block :: java
6566
6667 DataSource dataSource = ... ;
6768 EmployeeDao employeeDao = new EmployeeDaoImpl (dataSource);
6869 Employee employee = employeeDao. selectById(1 );
6970
70- また同様に、 ``Connection `` を指定してインスタンス化することも可能です。
71+ And also, it can instantiate with ``Connection `` specified explicitly.
7172
7273.. code-block :: java
7374
7475 Connection connection = ... ;
7576 EmployeeDao employeeDao = new EmployeeDaoImpl (connection);
7677 Employee employee = employeeDao. selectById(1 );
7778
78- Daoインタフェースはエンティティクラスと1対1で結びついているわけではありません。
79- ひとつのDaoインタフェースで複数のエンティティクラスを扱えます。
79+ Dao interface is no need to define as one to one with entity class.
80+ One dao interface can handle more than one entity classes.
8081
8182.. code-block :: java
8283
0 commit comments