-
Notifications
You must be signed in to change notification settings - Fork 26
Use Config file
@DB(configFile="db.cfg")
public interface TestDB{}
db.cfg file's content looks like this:
DB.cfg.url = jdbc:mysql://127.0.0.1:3306/test
DB.cfg.username = root
DB.cfg.password = root
-
sql.debug = false
[scope: DB]
If show running SQL statements
-
url =
[scope: DB]
the JDBC url, for example: jdbc:mysql://127.0.0.1:3306/world
-
driver = com.mysql.jdbc.Driver
[scope: DB]
the JDBC driver class
-
username = root
[scope: DB]
the database username
-
password =
[scope: DB]
the database password
-
catalog =
[scope: DB]
the database catalog
-
schema =
[scope: DB]
the database schema
-
tables = %
[scope: DB]
Indicates the table names to generate the model classes, "%": means all of tables.
For example: pre_%: all tables with the prefix: "pre_"
-
mapping =
[scope: DB]
Table name's mapping, For example: table_123=ModelX;table123=ModelY...
-
partitions =
[scope: DB]
Define partition tables
-
datasourceClass =
[scope: DB]
Data source class, the value can be C3p0DataSource or DruidDataSource or other class which implementations of the class: com.tsc9526.monalisa.orm.datasource.PooledDataSource
-
datasourceDelayClose =
[scope: DB]
After database configuration reload, delay closing data source that has been opened
-
history.db =
[scope: DB]
The history table is saved in the database.
-
history.prefix.table = history_
[scope: DB]
Prefix of history tables
-
history.prefix.column = history_
[scope: DB]
Column's prefix in the history tables
-
history.tables =
[scope: DB]
Those tables need to record changes in history. %: means all of tables
-
multi.resultset.deepth = 100
[scope: DB]
Useful when only the SQL query return multiple results
-
cache.tables =
[scope: DB]
Which tables will be cached
-
modelClass =
[scope: TABLE]
A base mode class, which inherits from com.tsc9526.monalisa.orm.model.Model
-
modelListener =
[scope: TABLE]
A listen class when model changed
-
validate = false
[scope: TABLE]
Whether you need to verify the data before you save it
-
validator =
[scope: TABLE]
The model validator class
-
cache.class =
[scope: TABLE]
The cache class
-
cache.name = default
[scope: TABLE]
The name of cache setting
-
cache.eviction = LRU
[scope: TABLE]
The cache eviction's algorithm
-
auto.create_time = create_time
[scope: TABLE]
When calling Model.save(), auto set model field's value if exists: create_time
-
auto.update_time = update_time
[scope: TABLE]
When calling Model.update(), auto set model field's value if exists: update_time
-
auto.create_by = create_by
[scope: TABLE]
When calling Model.save(), auto set model field's value if exists: create_by
You need to set up thread context by call:
Tx.put(CONTEXT_CURRENT_USERID,"the_operate_user_id");
-
auto.update_by = update_by
[scope: TABLE]
When calling Model.update(), auto set model field's value if exists: update_by
You need to set up thread context by call:
Tx.put(CONTEXT_CURRENT_USERID,"the_operate_user_id");
-
exception_if_set_field_not_found = false
[scope: TABLE]
If true, throw a exception if set a not exists field in a model, otherwise false.
-
DB
Meaning: this property is a configuration item for a database scope level
-
TABLE
Meaning: this property is a configuration item for a table scope level,
you can specify a value for each table. for example:
DB.cfg.modelClass = MyBaseModelClassName
DB.cfg.modelClass.user = MyUserModelClassName
All generated model classes which inherits from MyBaseModelClassName except for model: "user", the model: "user" will inherits from MyUserModelClassName