在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):institut-de-genomique/hibernatetools-gradle-plugin开源软件地址(OpenSource Url):https://github.com/institut-de-genomique/hibernatetools-gradle-plugin开源编程语言(OpenSource Language):Groovy 100.0%开源软件介绍(OpenSource Introduction):Hibernatetools-gradle-pluginsPurposeThis plugin intend to ease hibernatetools through gradle. It offer three tasks:
UsageInside your build.gradle file add this: Build script snippetFor Gradle 2.1 and after:plugins {
id "org.hibernate.gradle.tools" version "1.2.4"
} For older Gradle release:buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.org.hibernate.gradle.tools:hibernatetools-gradle-plugin:1.2.4"
}
}
apply plugin: "org.hibernate.gradle.tools" Fallback to hibernate-tools 5.2This project has been updated to use hibernate-tools-5.3.4.Final but 5.2.x is still supported. To override the hibernate-tools version add:
to your build.gradle's main Configure the databaseNow you have only to configure the database, by using database section inside build.gradle file. Example: If using domain, database{
basePackage = "com.project.database.model"
url = "jdbc:mysql://myDB.domain.fr"
} If using host, database{
basePackage = "com.project.database.model"
url = "jdbc:mysql://host"
dbName = "myDB"
}
This plugin allow to specify multiple catalog using: import org.hibernate.gradle.tools.*
database{
catalog = [ "catalog1": new Schema("schemaY", [".*"])), "catalog2": new Schema("schemaX", [".*"]) ]
basePackage = "org.foo.bar"
} This plugin allow to specify multiple schema using: database{
catalog = [ "catalog1": new Schema("schemaX", ["tableY"]), "catalog2": new Schema("schemaY", [".*"]) ]
basePackage = "org.foo.bar"
}
This plugin allow to specify multiple tables using: database{
catalog = [ "catalog1": new Schema("schemaX", ["tableY","tableZ"]), "catalog2": new Schema("schemaY", [".*"]) ]
basePackage = "org.foo.bar"
}
The symbol '.*' means any characters repeated 0 on n times. In given example class will be mapped from foo and bar tables and also any table where name start with other The config files hibernate-tools needs are generated by the database{
configXml = "/tmp/hibernate.cfg.xml" // <<---- path to config file for hibernate-tools 5.2.x
hibernatePropertiesFile = "/tmp/hibernate.properties" // <<---- path to config properties file for hibernate-tools 5.3.x
revEngXml = "/tmp/hibernate.reveng.xml" // <<---- path to reveng file
} by default database section are defined as: class Database {
def catalog = [".*":new Schema(".*", ".*")] // Schema parameter are: schema pattern name, table pattern name
String user = ""
String password = ""
String url = "jdbc:mysql://127.0.0.1"
Integer port = 3306
String dbName = ""
String driver = "com.mysql.jdbc.Driver"
String dialect = "org.hibernate.dialect.MySQLDialect"
String basePackage = "com.project.database.model"
} dialect and driver to use are located on hibernate Reverse engineeringOnce the plugin is declared and database connection defined to get java classes you need only to run this command: $ gradle hbm2dao This plugin provides three gradle target:
enjoy |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论