Drivers Doma

Posted on  by 

Contents

  • Gen task
    • Configuration data types
    • Examples
Drivers Doma

Gen task is the only task in Doma-Gen.

Drivers

Indicate dependencies on Doma-Gen and a JDBC driver with custom configurations domaGenRuntime. Specify domagentask.properties to the ant.taskdef ’s resource parameter. Specify the classpath of domaGenRuntime to the ant.taskdef ’s classpath parameter. Lorry driver Doma Dumitru, 41, had been hoping to spend tomorrow with his wife Alina, 40, and their 12-year-old daughter Daria Maria back home at Oradea in north-west Romania. He has been stuck in. Dovado DOMA Router Firmware 7.3.16. It is highly recommended to always use the most recent driver version available. Try to set a system restore point before installing a device driver. This will help if you installed an incorrect or mismatched driver. Problems can arise when your hardware device. Dovado DOMA Router Firmware 7.3.15. It is highly recommended to always use the most recent driver version available. Try to set a system restore point before installing a device driver. This will help if you installed an incorrect or mismatched driver. Problems can arise when your hardware device.

The Gen task uses following data types:

Top level parameters are as follows:

ParameterDescriptionDefault valueRequired
urlA database url of the form jdbc:subprotocol:subname.YES
userA database user.YES
passwordA database password.YES
driverClassNameA JDBC driver class name.Inferred from the url value.
dialectName
One of following values is available:
mssql, oracle, db2.
Inferred from the url value.
dialectClassNameA dialect class name used in Doma runtime.Inferred from the url value.
genDialectClassName
The class must be in CLASSPATH of Doma-Gen runtime.
Inferred from the url value.
schemaNameA target schema.
tableNamePatternA regex pattern of target tables. (case insensitive).*
ignoredTableNamePatternA regex pattern of non-target tables. (case insensitive).*$.*
tableTypes
For example, specify “TABLE, VIEW”
TABLE
versionColumnNamePattern
The regex pattern of version columns. (case insensitive)
be annotated with @Version.
templateEncodingThe encoding for Freemarker template filesUTF-8
templatePrimaryDir
The primary directory for Freemarker template files.
in this directory.
globalFactoryClassName
It must implement
org.seasar.doma.extension.gen.GlobalFactory

This data type represents the configuration for entity and entity listener classes.The parameter definitions are as follows:

ParameterDescriptionDefault valueRequired
generateIf true, the Java files are generated.true
destDirThe destination directory for generated Java files.src/main/java
encodingThe encoding for generated Java files.UTF-8
overwrite
are overwritten.
true
overwriteListeneroverwriteListenerIf true, the Java files of entity listenerclasses are overwritten.false
packageNameThe package for entity classes.
entityPrefixThe prefix of entity classes.
entitySuffixThe prefix of entity classes.
superclassName
The full qualified name of superclass of entity classes.
The class must be in CLASSPATH of Doma-Gen runtime.
listenerSuperclassName
entity listener class.
namingType
One of the following value is available:
snake_lower_case, upper_case, lower_case.
the @Entitynaming element.
entityPropertyClassNamesFileThe file used to resolve entity property classes.
generationType
One of the following value is available:
This value is valid only if the table has single primary key.
the @GeneratedValue’s strategy element.
initialValue
This value is valid only if the generationType is
This value is reflected in the initialValue element of
allocationSize
This value is valid only if the generationType is
This value is reflected in the allocationSize element of
useAccessor
entity class field.
with a public modifier.
true
useListener
If true, the code of entity listeners are generated.
the @Entitylistener element.
true
showDbComment
in JavaDoc comments.
true
showCatalogName
in the @Table’s catalog element.
false
showSchemaName
in the @Table’s schema element.
false
showTableName
in the @Table’s name element.
true
showColumnName
in the @Column’s name element.
true
originalStatesPropertyName
The property to be annotated with @OriginalStates.
sql
An SQL statement. Code of an entity class is generated from
entityName
The entity class name which will be generated from
This value is valid only if the sql have a value.
Example

This data type represents the configuration for DAO interfaces.The parameter definitions are as follows:

ParameterDescriptionDefault valueRequired
generateIf true, the Java files are generated.true
destDirThe destination directory for generated Java files.src/main/java
encodingThe encoding for generated Java files.UTF-8
overwrite
are overwritten.
false
packageNameThe package for DAO interfaces.example.dao
suffixThe suffix of DAO interfaces.Dao
configClassName
This value is reflected in the @Dao’s config element.
false

This data type represents the configuration for SQL files.

This data type can generate two SQL files.Each of the SQL files contains SELECT statement whose search condition is:

  • An identifier only.
  • The pair of an identifier and a version.

But there are exceptions:

  • If an entity doesn’t have the identifier, neither SQL files are generated.
  • If an entity doesn’t have the version, the second SQL file is not generated.

You can generate arbitrary SQL files if you prepare Freemarker template files.

The parameter definitions are as follows:

Drivers
ParameterDescriptionDefault valueRequired
generateIf true, SQL files are generated.true
destDirThe destination directory for generated SQL files.src/main/resources
overwriteIf true, SQL files are overwritten.true

This data type represents the configuration for Java test cases for SQL files.

The parameter definitions are as follows:

ParameterDescriptionDefault valueRequired
generateIf true, Java files for SQL tests are generated.true
destDirThe destination directory for generated Java files.src/test/java
encodingThe encoding for generated Java files.UTF-8

FileSet as a nested element¶

To find the target SQL files, use the FileSet element.

The SQL files meet following conditions:

  • The extension of them is sql.
  • They are located in directories below a “META-INF” directory.

You can use the Gen task with Gradle.Write your build script as follows:

There are important points:

  • Indicate dependencies on Doma-Gen and a JDBC driver with custom configurations domaGenRuntime.
  • Specify domagentask.properties to the ant.taskdef’s resource parameter.
  • Specify the classpath of domaGenRuntime to the ant.taskdef’s classpath parameter.

Driver Domain Xen

We show you typical use cases using Gradle.

Define the following task:

This task generates following files:

  • Java files for entity classes
  • Java files for entity listeners classes
  • Java files for DAO interface
  • SQL files

Define the following task:

This task generates the following Java file:

Drivers

It is convenient to use a -P option of Gradle to pass parameters from a command line:

Define the following task:

You can generate entity classes whose property type is user defined type.To do so, you have to define mappings in a properties file.

For example, suppose you want to generate the entity class example.entity.Employee andthe class have properties firstName and lastName.To map the properties to the example.domain.Name class,write the properties file as follows:

The key part is example.entity.Employee@.*Name$ and the value part is example.domain.Name.

In the key part, the left side of @ is the entity class name, and the right side of @is property name represented as a regex pattern.

With the definition, the following code is generated:

To apply the definition to all entity classes not only to example.entity.Employee,remove example.entity.Employee@ from the key part:

Specify the properties file to the EntityConfig’s entityPropertyClassNamesFile parameter:

Default template files are located inthe source code repository of Doma-Gen.

The template files are as follows:

Template fileData model classGenerated file
entity.ftlorg.seasar.doma.extension.gen.EntityDescJava files for entity classes
entityListener.ftlorg.seasar.doma.extension.gen.EntityListenerDescJava files for entity listener classes
dao.ftlorg.seasar.doma.extension.gen.DaoDescJava files for DAO interfaces
sqlTestCase.ftlorg.seasar.doma.extension.gen.SqlTestCaseDescJava files for SQL tests
selectById.sql.ftlorg.seasar.doma.extension.gen.SqlDescSQL files
selectByIdAndVersion.sql.ftlorg.seasar.doma.extension.gen.SqlDescSQL files

To create custom template files, copy them and modify their contents without changing file names.Then put them in the directory which is specified to the templatePrimaryDir parameter.

For example, if you put them in the directory “mytemplate”,specify “mytemplate” to the templatePrimaryDir parameter:

Define a copyright header in the lib.ftl file as follows:

Drivers Doma

Then put the the lib.ftl in a directory andspecify the directory to the templatePrimaryDir parameter:

Define an author in the lib.ftl file as follows:

Domaudeo Drivers

Then put the the lib.ftl in a directory andspecify the directory to the templatePrimaryDir parameter:

Doma 2 is a database access framework for Java 8+.Doma has various strengths:

  • Verifies and generates source code at compile time using annotation processing.
  • Provides type-safe Criteria API.
  • Supports Kotlin.
  • Uses SQL templates, called “two-way SQL”.
  • Has no dependence on other libraries.

This document consists of following sections:

Help improve our documentation

Have feedback or a question? Found a typo?

Please add an issue or pull request tohttps://github.com/domaframework/doma and we’ll get back to you.

  • Getting started
  • Configuration
  • Basic classes
  • Domain classes
  • Embeddable classes
  • Entity classes
  • Dao interfaces
  • Queries
  • Query builders
  • Criteria API
  • SQL templates
  • Expression language
  • Transaction
  • Building an application
  • Annotation processing
  • Lombok support
  • Kotlin support
  • SLF4J support

Coments are closed