Contents
- Gen task
- Configuration data types
- Examples
Gen task is the only task in Doma-Gen.
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:
Parameter | Description | Default value | Required |
---|---|---|---|
url | A database url of the form jdbc:subprotocol:subname . | YES | |
user | A database user. | YES | |
password | A database password. | YES | |
driverClassName | A JDBC driver class name. | Inferred from the url value. | |
dialectName | One of following values is available: mssql , oracle , db2 . | Inferred from the url value. | |
dialectClassName | A 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. | |
schemaName | A target schema. | ||
tableNamePattern | A regex pattern of target tables. (case insensitive) | .* | |
ignoredTableNamePattern | A 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 . | ||
templateEncoding | The encoding for Freemarker template files | UTF-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:
Parameter | Description | Default value | Required |
---|---|---|---|
generate | If true , the Java files are generated. | true | |
destDir | The destination directory for generated Java files. | src/main/java | |
encoding | The encoding for generated Java files. | UTF-8 | |
overwrite | are overwritten. | true | |
overwriteListeneroverwriteListener | If true , the Java files of entity listenerclasses are overwritten. | false | |
packageName | The package for entity classes. | ||
entityPrefix | The prefix of entity classes. | ||
entitySuffix | The 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 @Entity ’ naming element. | ||
entityPropertyClassNamesFile | The 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 isThis value is reflected in the initialValue element of | ||
allocationSize | This value is valid only if the generationType isThis 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 @Entity ’ listener 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:
Parameter | Description | Default value | Required |
---|---|---|---|
generate | If true , the Java files are generated. | true | |
destDir | The destination directory for generated Java files. | src/main/java | |
encoding | The encoding for generated Java files. | UTF-8 | |
overwrite | are overwritten. | false | |
packageName | The package for DAO interfaces. | example.dao | |
suffix | The 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:
Parameter | Description | Default value | Required |
---|---|---|---|
generate | If true , SQL files are generated. | true | |
destDir | The destination directory for generated SQL files. | src/main/resources | |
overwrite | If 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:
Parameter | Description | Default value | Required |
---|---|---|---|
generate | If true , Java files for SQL tests are generated. | true | |
destDir | The destination directory for generated Java files. | src/test/java | |
encoding | The 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 theant.taskdef
’sresource
parameter. - Specify the classpath of
domaGenRuntime
to theant.taskdef
’sclasspath
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:
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 file | Data model class | Generated file |
---|---|---|
entity.ftl | org.seasar.doma.extension.gen.EntityDesc | Java files for entity classes |
entityListener.ftl | org.seasar.doma.extension.gen.EntityListenerDesc | Java files for entity listener classes |
dao.ftl | org.seasar.doma.extension.gen.DaoDesc | Java files for DAO interfaces |
sqlTestCase.ftl | org.seasar.doma.extension.gen.SqlTestCaseDesc | Java files for SQL tests |
selectById.sql.ftl | org.seasar.doma.extension.gen.SqlDesc | SQL files |
selectByIdAndVersion.sql.ftl | org.seasar.doma.extension.gen.SqlDesc | SQL 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:
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