Code Monkey home page Code Monkey logo

doma's Introduction

Doma version 1

Doma is a Database access framework for Java 6 and above.

Doma uses Annotation Processing Tool to generate source code and validate sql mappings at compile time.

CI Google group : doma-user project chat

Notice

Maintenance Policy

We accept only bug fixes for Doma 1. We are going to include new features in Doma 2.

Documentation

http://doma.seasar.org/

Google Group

https://groups.google.com/g/doma-user

Chatroom

https://domaframework.zulipchat.com

Build with Maven

To build with Maven, add the dependency listed below to your pom.xml file:

<dependency>
  <groupId>org.seasar.doma</groupId>
  <artifactId>doma</artifactId>
  <version>1.38.2</version>
</dependency>

In addition, if you use Doma 1.38.0 and below, add the repository listed below to your pom.xml file:

<repositories>
  <repository>
    <id>maven.seasar.org</id>
    <name>The Seasar Foundation Maven2 Repository</name>
    <url>http://maven.seasar.org/maven2</url>
  </repository>
</repositories>

Build Doma 1 from Source

Install JDK 8.

Clone the repository and Run the maven command as follows:

$ git clone https://github.com/seasarorg/doma.git
$ cd doma/doma
$ ./mvnw clean install

Issues

version 1.37.0 and above

https://github.com/seasarorg/doma/issues

version 1.36.0 and below

https://www.seasar.org/issues/projects/DOMA/issues

License

Apache License, Version 2.0

doma's People

Contributors

backpaper0 avatar bufferings avatar dependabot[bot] avatar gakuzzzz avatar itmammoth avatar nakamura-to avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doma's Issues

エンハンスされたPOJOから値が取れない

いつもお世話になっております。

現在、DomaをSpringと一緒に使ってまして、コンテナ管理されているPOJOをDaoメソッドに渡しても、SQL組み立て時にパラメータで受け取ったPOJOから値が取れない状況です。

org.seasar.doma.internal.expr.ExpressionEvaluator#getFieldValueでtargetから値が取れてません。

POJOをコンテナ管理にしているので、CGLIBでエンハンスされ、
クラスが Hoge$EnhancerByCGLIB$$xxxxxx のようになってますが、
Fieldは元のクラス(Hoge)の情報を使っているからだと思っています。

newしたHogeを渡すと値が取れます。

良い解決策があれば教えてください。

DaoGeneratorをカスタマイズ出来るのであれば、エンハンス元のクラスのインスタンスを生成してディープコピーしようかなと思ってます。

POJO

@Named
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS, value = "request")
public class Hoge {
    private String fuga;
    // getter, setter省略
}

Dao

@Dao
@DaoConfig  // Spring連携用の自作アノテーション
public interface ChargeRepository {
    @Insert(sqlFile = true)
    int create(String p0, Hoge hoge);
}

SQLファイル

insert into table01
select *
     , /*hoge.fuga*/'a'     -- hoge.fugaがnullになる
  from table02
 where col1 = /*p0*/'a'

doma logo icon

Hi
It would be nice to have a logo icon or image of doma so that we can use it for introducing doma.

@infixについて

お世話になります。

@infixについて質問となりますが、
Doma2では%abc%のように生成されるのでしょうか?
それとも%abc%のように生成されるのでしょうか?

よろしくお願いいたします。

Daoのインターセプタから元のアノテーションが取得しづらい

インターフェースかつメソッドに定義されたアノテーションは継承されないため、Daoに適用したインターセプタから@selectなどのアノテーションの情報を取得しようとすると、実装クラスから親を辿って@daoが定義されたインターフェースを探し、そのインターフェース定義にある同名かつ互換性のある型の引数を持つメソッドを探し、そのアノテーションを取得するというステップが必要になります。
特にオーバーロードされたメソッドがいくつもあると、正しく「同名かつ互換性のある型の引数を持つメソッドを探す」のが複雑で、またそれなりに遅くなりそうです。

そのため、Daoのインターフェースに定義された@selectなどのアノテーションを、自動生成された実装クラスにも引き継いで定義することを検討していただけないでしょうか。

Invalid insert query for an entity only with auto generated ID column.

Hi,

It seems that Doma creates wrong insert sql for an entity only with auto generated ID column like this:

insert into ID_ONLY) values)

It might be better to generate following query:

insert into ID_ONLY() values ()

I'm glad if you kindly share your opinion about this issue.
I will send a pull request.

実行したSQLを取得したい

お世話になります。

「アプリで発行された更新系SQLを全てDBに保存する」という要件があるのですが、
Loggerで取れる上記の情報をアプリ側で取得する方法はありますか?

以前は、Seasar2(Teeda + S2Dao)を使っていたのですが、
その時はインターセプタ内で、SqlLogRegistryLocator.getInstance().getLast()で取得して記録していました。

今使っているDIコンテナはSpringです。

よろしくお願いします。

SQLの先頭に自動でコメントを付与したい

はじめまして。

以下の要望が現在の仕組みで実現可能かお聞きしたいです。
もしくは、今後の機能拡張案としていただけると幸いです。

要望:SQLの先頭に自動でコメントを付与したいです。

理由:RDB側でリストアップされた遅いSQLの先頭にあるコメントを見て、
   アプリ側(該当SQLの実行元)と紐付けたいためです。
   リストアップされたSQLは後ろが切れたりWhere句が変わるため、該当SQLを探すのが困難です。

備考:コメントはRDB側とアプリ側で紐付け出来れば何でも構いません。
   SQLファイルパスが付与できれば分かりやすいです。
   主にSQL数が多く、似たSQLが多いアプリケーションで需要があると考えます。
   パフォーマンス問題が発生した際、該当SQLの実行元を調査する際に有用です。
   手動でコメントを付与するのは、量の多さや記法の不統一の恐れから避けたいです。
   Domaで実現せず、アプリとDBを透過的に監視するソリューションを使う案もあるとは思います。

自身で変更する場合の案:
   ソースを拝見した限りでは、prepareSqlメソッドの付近で処理を新規追加するのが楽だと思いました。
   見栄えを考えると、DaoImplクラスの__query.set*** の並びにあると分かりやすいと思いました。

@OriginalStatesがあるEntityを複数回UPDATEしたときの挙動

@OriginalStatesがあるEntityの値を変えながら複数回UPDATEすると、2回目以降のUPDATEで変更した項目が正しく反映されないことがあります。

次のようなテストコードで検証できるのですが、2回目以降のUPDATEの際に最初のSELECT時の値と同じ値に変更すると、正しく変更が検知されていないようです。

HogeEntity entity = new HogeEntity();
entity.setId(1);
entity.setValue("A");
dao.insert(entity);

entity = dao.selectById(1);

entity.setValue("X"); //Xに更新
dao.update(entity);

entity.setValue("A"); //Aに戻す
dao.update(entity);

HogeEntity actual = dao.selectById(1);

assertEquals("A", actual.getValue());

PostUpdateの処理の中で毎回@OriginalStatesに更新時の値を反映するようにすれば解決しそうですが、この挙動は意図した仕様なのでしょうか?

DaoにCDIのインターセプタを適用するとエラーになる

自動生成されたDaoの実装クラスに引数なしのコンストラクタが無いため、CDIによってインスタンス化される際にエラーになります。

下記リンク先が参考になりますが、OpenWebBeansによるCDI実装でインターセプタが適用される場合、まず引数ありのコンストラクタを呼び出してインスタンスを作成した後に、プロキシークラスを生成して引数なしのコンストラクタを呼び出すので、そこでエラーになります。

http://stackoverflow.com/questions/15637391/should-cdi-bean-with-interceptors-have-a-default-constructor

CDIの仕様も確認してみたところ、Managede Beanとしては引数なしのコンストラクタが必須ではないのですが、プロキシー化が必要な場合には引数なしのコンストラクタが必須となっています。

WeldによるCDI実装では問題なさそうなのですが、OpenWebBeansによるCDI実装では仕様としてエラーになっているようです。

自動生成されたDaoの実装クラスに引数なしのコンストラクタを追加するようにDomaの改善を検討してみていただけないでしょうか。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.