This is a test demo program for Jdao. All sample programs can run directly without additional database connections, as the data has already been packaged within the project.
The demo program tests the following aspects:
How to automatically generate standardized entity classes builder_example
CRUD operations, transactions, and batch processing for standardized entity classes dao_example
Serialization of standardized entity classes serialize_example
CRUD operations, transactions, etc., using native SQL nativesql_example
How to create dynamic native SQL with SqlBuilder nativesql_exampleSqlBuilderDemo
Usage of XML-mapped SQL mapper_example
How to use dynamic SQL in XML-mapped SQL mapper_exampleDynamicDemo
Example of read-write separation Slave
Example of data caching Cache
Example of data table migration DataTransfer
Example of data table backup DataBackup
For detailed usage of Jdao, please refer to the documentation.
// Select operation@Testpublicvoidselect() throwsException {
List<DataBean> dblist = Jdao.executeQueryBeans("select * from Hstest1 order by id desc limit 5");
for (DataBeandataBean : dblist) {
System.out.println(dataBean);
}
}
// Insert operation@Testpublicvoidinsert() throwsException {
Jdao.executeUpdate(tx, "insert into hstest1(`rowname`,`value`) values(?,?)", "uuuuu>>>>1", "ppppppppp");
tx.commit();
}
Mapper Mapping Module
Example 1
<selectid="selectHstestById"parameterType="int"resultType="io.github.donnie4w.jdao.dao.Hstest">
SELECT * FROM hstest WHERE id < #{id} AND age < #{age}
</select>
<selectid="selectHstest1"parameterType="int"resultType="io.github.donnie4w.jdao.dao.Hstest1">
SELECT * FROM hstest1 WHERE id > 1 AND id < 10 LIMIT #{limit}
</select>