- Add annotation to the table class:
Table,IdandColumn; - Add a child class for the
JdbcUtilsclass; - Initialization the child class by uri, username, password and parameters array;
- Use
JdbcUtils#Connection()function to connect to the MySQL database; - You can use
insert,updateById,deleteByIdandselectById; - You can use
deleteandselectfunction; - NOW you can use
setAutoCommit(),commit(),rollback(),rollback(sp)andgetSavepoint()to transactional.
- If you MySQL database have used
datetime, it can only be converted intoString; - It supports
int,Integer,double, 'DoubleandString`. - The function
selecthas a parameterwhere, equals SQL's, but now it is only support=. Thedeletefunction also.
This code is mainly referenced 【Java进阶】实现自己的ORM框架.