DOMA Designated Driver is a team of matured and professional drivers with integrity who know SAFETY is paramount and are ready to drive you home safely. Our aim/objective is to get you and your vehicle home safely when your ability to safely drive your own vehicle has been impaired. Section 3 of the so-called 'Defense of Marriage Act' has been declared unconstitutional by the US Supreme Court. Committed same-sex couples who are legally married in their own states can now receive federal protections - like Social Security, veterans' benefits, health insurance and retirement savings.
Contents
- Gen task
- Configuration data types
- Examples
Gen task is the only task in Doma-Gen.
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.
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:
Then put the the lib.ftl
in a directory andspecify the directory to the templatePrimaryDir
parameter:
Dorma Drive
Contents
- Configuration
- Configurable items
- Configuration definition
The configurable items must be returned from the methods of the implementation class ofthe org.seasar.doma.jdbc.Config
interface.
Return a JDBC DataSource
from the getDataSource
method.If you need local transactions provided by Doma, return a LocalTransactionDataSource
.
See also: Transaction
Return a DataSource’s name from the getDataSourceName
method.In the environment where multiple DataSources are used, the name is important.You have to give an unique name to each DataSource.
The default value is the full qualified name of the implementation class of Config
.
Return a Dialect
from the getDialect
method.You have to choose an appropriate dialect for the database you use.
Doma provides following dialects:
Database | Dialect Name | Description |
---|---|---|
DB2 | Db2Dialect | |
H2 Database Engine 1.2.126 | H212126Dialect | H2 Database Engine 1.2.126 |
H2 Database | H2Dialect | H2 Database Engine 1.3.171 and above |
HSQLDB | HsqldbDialect | |
Microsoft SQL Server 2008 | Mssql2008Dialect | Microsoft SQL Server 2008 |
Microsoft SQL Server | MssqlDialect | Microsoft SQL Server 2012 and above |
MySQL | MySqlDialect | |
Oracle Database 11g | Oracle11Dialect | Oracle Database 11g |
Oracle Database | OracleDialect | Oracle Database 12g and above |
PostgreSQL | PostgresDialect | |
SQLite | SqliteDialect |
These dialect are located in the org.seasar.doma.jdbc.dialect
package.
Return a JdbcLogger
from the getJdbcLogger
method.
Doma provides following JdbcLogger:
- org.seasar.doma.jdbc.UtilLoggingJdbcLogger
The default JdbcLogger is UtilLoggingJdbcLogger which uses java.util.logging
.
Return a SqlFileRepository
from the getSqlFileRepository
method.
Doma provides following SqlFileRepositories:
- org.seasar.doma.jdbc.GreedyCacheSqlFileRepository
- org.seasar.doma.jdbc.NoCacheSqlFileRepository
The default SqlFileRepository is GreedyCacheSqlFileRepositorywhich caches the result of SQL parsing without limitation.
Return a RequiresNewController
from the getRequiresNewController
method.RequiresNewController may begin new transactions to makes transaction locked time shorter.
This feature is used only when you use @TableGenerator
which generates identities with the table.
The default RequiresNewController does nothing.
Return a ClassHelper
from the getClassHelper
method.
When the application server and framework you use loads classes with their specific way,consider to create your own ClassHelper.
The default ClassHelper loads classes with Class#forName
mainly.
Return a SqlLogType
from the getExceptionSqlLogType
.The default SqlLogType contains the formatted SQL in exception messages.
Return a UnknownColumnHandler
from the getUnknownColumnHandler
method.In result set mappings, if an unknown column to an entity class is found,the UnknownColumnHandler handles the situation.
The default UnknownColumnHandler throws an UnknownColumnException
.
Return a Naming
from the getNaming
method.The naming element of @Entity
have preference over this value.When you specify explicit value to the name elements of @Table
and @Column
,the naming convention is not applied to them.
The default Naming does nothing.
Return a MapKeyNaming
from the getMapKeyNaming
method.The MapKeyNaming is used when the result set is mapped to java.util.Map<String,Object>
.
The default MapKeyNaming does nothing.
Return a LocalTransactionManager
from the getTransactionManager
method.The getTransactionManager
method throws UnsupportedOperationException
as default.
See also: Transaction
Doma Drivers Ed
Return a Commenter
from the getCommenter
method.
Doma provides following commenter:
- org.seasar.doma.jdbc.CallerCommenter
The default Commenter does nothing.
Return a CommandImplementors
from the getCommandImplementors
method.For example, the CommandImplementors provides you a hook to execute JDBC API.
Return a QueryImplementors
from the getQueryImplementors
method.For example, the QueryImplementors provides you a hook to rewrite SQL statements.
Return the query timeout (second) from the getQueryTimeout
method.This value is used as default in Queries.
Return the max rows from the getMaxRows
method.This value is used as default in Search.
Return the fetch size from the getFetchSize
method.This value is used as default in Search.
Return the batch size from the getBatchSize
method.This value is used as default in Batch insert,Batch update and Batch delete.
Return a EntityListenerProvider
from the getEntityListenerProvider
method.When you want to get entity listeners from a dependency injection container,create your own EntityListenerProvider.
The default EntityListenerProvider get the entity listener from the accepted supplier.
All JDBC drivers are loaded automatically by the service provider mechanism.
Warning
But in the specific environment, the mechanism doesn’t work appropriately.For example, when you use Apache Tomcat, you will find the case.See also: DriverManager, the service provider mechanism and memory leaks
The simple definition is appropriate in following cases: Drivers diagnostic instruments cameras.
Dorma Drive Reamstown Pa 17567
- The configuration instance isn’t managed in the dependency injection container
- Local transactions is used
You can use the above DbConfig
class as follows:
The above EmployeeDao
interface must be annotated with the @Dao
annotation as follows:
Doma Drivers License Center
The advanced definition is appropriate in following cases:
Dome Driver
- The configuration instance is managed as a singleton object in the dependency injection container
- The transaction manager is provided from the application server or framework you use
Dora Drive Rochester Nh
Suppose the dialect
and the dataSource
are injected by the dependency injection container:
Doma Designated Driver
To inject the instance of the above class to your DAO implementation instance,you have to annotate your DAO interfaces with @AnnotateWith
:
To avoid annotating your DAO interfaces with @AnnotateWith
repeatedly,annotate the arbitrary annotation with it only once:
Then, you can annotate your DAO interfaces with the above @InjectConfig
annotation: