Giter Club home page Giter Club logo

doma-gen's People

Contributors

fredge avatar matsumana avatar nakamura-to avatar nesheep5 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

doma-gen's Issues

カラムがnot null かどうか取得したい

一点質問させてください。

domagenで作ったjavaクラスでカラムがNotNullのプロパティに対して、
@NotNullをつけたいと考えています。

そこで質問です。
entity.ftl内でcolumnmetaのnullableの値を参照できれば実現可能と考えているのですが
可能でしょうか。
https://github.com/domaframework/doma-gen/blob/master/src/main/java/org/seasar/doma/extension/gen/ColumnMeta.java

EntityPropertyDescにはColumnMetaの情報を持っていないようだったので
やり方がわからず(そもそもできるのかがわからず)質問させていただいた次第です。
https://github.com/domaframework/doma-gen/blob/master/src/main/java/org/seasar/doma/extension/gen/EntityPropertyDesc.java

EntityクラスのEnum対応についての質問

作成されるEntityのフィルドはDBの定義により出力されると思いますが、Enumに対応するように出力可能でしょうか?

※後entityConfigにsuperclassNameを指定したらエラーになります。
参考になるページなどあるでしょうか?

configurations {
    domaGenRuntime
}
repositories {
    mavenCentral()
    maven {url 'https://oss.sonatype.org/content/repositories/snapshots/'}
}

dependencies {
    domaGenRuntime 'org.seasar.doma:doma-gen:2.18.0'
    domaGenRuntime 'org.mariadb.jdbc:mariadb-java-client:2.1.2'
}


task gen << {
    ant.taskdef(resource: 'domagentask.properties',
            classpath: configurations.domaGenRuntime.asPath)
    ant.gen(url: 'jdbc:mariadb://xxx:3306/test',dialectName:"mysql",driverClassName:"org.mariadb.jdbc.Driver", user: 'test', password: 'test',templatePrimaryDir: "src/domaTemplate") {
        entityConfig(
                 superclassName:'samples.domain.DomaEntity'
                ,packageName:'samples.domain.entity',originalStatesPropertyName:"original",useListener:true
                ,listenerSuperclassName:'samples.domain.entity.DomaEntityListener'
                ,overwrite: true
        )
        daoConfig(packageName:'samples.dao',suffix:"DaoGen" ,overwrite:true)
        sqlConfig()
    }
}

Daoファイルを正しく生成できません。

EntityのpackageNameを4階層以上指定した場合、生成したDaoクラスには、Entityクラスのimport宣言はなくなります。

例:
task gen << {
ant.taskdef(resource: 'domagentask.properties',
classpath: configurations.domaGenRuntime.asPath)
ant.gen(url: 'jdbc:mysql://localhost:3306/dbname?useUnicode=true&characterEncoding=UTF-8&useSSL=false', user: 'username', password: 'password') {
entityConfig(packageName: 'jp.co.abc.entity',useListener: false)
daoConfig(packageName: 'jp.co.abc.dao')
sqlConfig()
}
}

Entity作成時にテーブルのPRIMARY KEYのカラムが複数ある場合、AUTO_INCREMENTカラムに@GeneratedValueがつかない

MYSQL V5.7.xの場合、以下のテーブルに対してAUTO_INCREMENT カラムに@GeneratedValueが付かない。

・DDL
CREATE TABLE TEST
(
ID INT NOT NULL AUTO_INCREMENT COMMENT 'ID',
DELETE_FLG BIT DEFAULT 0 NOT NULL COMMENT '削除フラグ',
VERSION INT DEFAULT 1 NOT NULL COMMENT 'バージョン',
PRIMARY KEY (ID, DELETE_FLG)
);

・作成されたEntity

public class Test {

/** ID */
@Id
@Column(name = "ID")
Integer id;

   ・・・・・

全スキーマのテーブル情報クラスが生成されてします

schemaNameオプションを指定しても、指定していないスキーマに属するテーブル情報が出力されてしまいます。

また、showSchemaName: trueを指定しても、出力されるエンティティクラスにスキーマ名が記載されていません。

スキーマ情報が取れていない(?)のかなと思います。
gradlewからの実行です。
java 1.8
mysql 5.7
Gradle 5.3

dependencies {
    domaGenRuntime 'org.seasar.doma:doma-gen:2.19.3'
    domaGenRuntime 'mysql:mysql-connector-java:8.0.13'
}

def basePackage = 'aaaaaaaaaaaaaaaaa'
def resourceDir = 'aaaaaaaaaaaaaaaaa'

task domaGen doLast {

    ant.taskdef(resource: 'domagentask.properties', classpath: configurations.domaGenRuntime.asPath)
    ant.gen(
            dialectName: "mysql"
            , driverClassName: "com.mysql.cj.jdbc.Driver"
            , schemaName : "xxxx"
            , url: "jdbc:mysql://127.0.0.1:3306/xxxx?useSSL=false&useUnicode=true&characterEncoding=utf8&nullNamePatternMatchesAll=true"
            , user: "root"
            , password: ""
            , templatePrimaryDir: "${resourceDir}/config/doma/templates"
            , ignoredTableNamePattern: "(sys_config") {
                entityConfig(
                        overwrite: "true"
                        , packageName: "${basePackage}.entity"
                        , useListener: "false"
                        , useAccessor: false
                        , entityPropertyClassNamesFile: "${resourceDir}/config/domagen/entityPropertyClassNameFile.properties"
                        , showSchemaName: true
                )
                daoConfig(
                        overwrite: "false"
                        , packageName: "${basePackage}.repository"
                )
                sqlConfig(
                        overwrite: "false"
                )
            }
}

この場合「xxxx」以外のスキーマ「yyyy」「zzzz」のエンティティ・リポジトリクラスが出力されます

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.