Doma Driver



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.

Doma

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:

Doma drivers education
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.

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:

Doma

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 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:

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.

Dora drive rochester nh

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:

DatabaseDialect NameDescription
DB2Db2Dialect
H2 Database Engine 1.2.126H212126DialectH2 Database Engine 1.2.126
H2 DatabaseH2DialectH2 Database Engine 1.3.171 and above
HSQLDBHsqldbDialect
Microsoft SQL Server 2008Mssql2008DialectMicrosoft SQL Server 2008
Microsoft SQL ServerMssqlDialectMicrosoft SQL Server 2012 and above
MySQLMySqlDialect
Oracle Database 11gOracle11DialectOracle Database 11g
Oracle DatabaseOracleDialectOracle Database 12g and above
PostgreSQLPostgresDialect
SQLiteSqliteDialect

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:

Dora drive mp4

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: