I didn't know Ibatis also has a similar hibernate like the automated Code generation tools, today to find abator This tool is also very good, on the ecelipse above a small try:
1. Access to Abator
Http://ibatis.apache.org/abator.html
Eclipse can automatically update to get this plugin, see the official installation steps
2. After installation, you will see a new file type Abator for IBATIS Configuration files, which is the Abator configuration file, and the details of the configuration file are described in the next menu Http://ibatis.apache.org/docs /tools/abator/, the filename defaults to Abatorconfig.xml, according to their actual needs to modify, I use the MySQL test here, the content is:
XML code
1.<abatorconfiguration> 2. <abatorContext> <!--todo:add Database Connection information--> 3. <!--Everyone here should know what it means.--> 4. <jdbcconnection driverclass= "Com.mysql.jdbc.Driver" 5. Connectionurl= "Jdbc:mysql://localhost:3306/lunjian" 6. Userid= "Root" 7. password= "Admin" > 8. <!--MySQL driver jar--> 9. <classpathentry location= "D:\Tomcat5\webapps\MoloonMarket\WEB-INF\lib\mysql-connector-java-5.0.4-bin.jar"/ > 10. </jdbcConnection> 11. <!--targetpackage Specifies a package name to store model Bean,targetproject is the project name--> 12. <javamodelgenerator targetpackage= "Com.itatis.domain" targetproject= "Mjtserver"/> 13. <!--sqlmapgenerator Specifies a package name to store sqlmap.xml--> 14. <sqlmapgenerator targetpackage= "Com.itatis.persistence.xml" targetproject= "Mjtserver"/> 15. <!--daogenerator Specifies a package name to store DAO and daoimpl--> 16. <daogenerator type= "IBATIS" targetpackage= "Com.itatis.persistence.sqlmapdao" targetproject= "Mjtserver"/> 17. <!--table name, can be multiple, default does not write columnoverride words to generate all fields--> 18. <table tablename= "Users" > 19. <!--<columnoverride column= "???" Property= "???"/>--> 20.
</table> 21. </abatorContext> 23.
</abatorConfiguration> 24. 25.t;abatorconfiguration>
<abatorContext> <!--todo:add Database Connection information--> <!--Here we all know what it means-->
<jdbcconnection driverclass= "Com.mysql.jdbc.Driver" connectionurl= "Jdbc:mysql://localhost:3306/lunjian" Userid= "root" password= "admin" > <!--mysql driver jar--> <classpathentry location= "D:\Tomcat5\ Webapps\moloonmarket\web-inf\lib\mysql-connector-java-5.0.4-bin.jar "/> </jdbcConnection> <!--targetp ACKAGE Specifies a package name to store the model Bean,targetproject is the project name--> <javamodelgenerator targetpackage= "Com.itatis.domain" targetproject= "Mjtserver"/> <!--sqlmapgenerator Specify a package name for storage sqlmap.xml--> <sqlmapgenerator targetPackage= "Com.itatis.persistence.xml" targetproject= "Mjtserver"/> <!--daogenerator Specify a package name to store the DAO and daoimpl--> <da Ogenerator type= "IBATIS" targetpackage= "Com.itatis.persistence.sqlmapdao" targetproject= "Mjtserver"/> <!--table name
, you can multiple, default does not write columnoverride words to generate all fields--> <table tablename= "Users" > <!--<columnoverride column= "???" Property= "???"/>--> </ Table> </abatorContext> </abatorconfiguration>
3. Right-click the configuration file and click Generate IBatis artifacts to generate the file.
That's how the basic files are generated,
Includes: Users.java,usersexample.java,usersdao.java,usersdaoimpl.java,users_ sqlmap.xml
Please note that this generated a usersexample.java, inherited from the Users.java, I personally think it is useless, DAO inside also contains a lot of commonly used interfaces, Daoimpl inside the implementation is entirely in accordance with the Ibatis to do, but relatively large, Use to remove some useless things sqlmap.xml This file is also large, impatient to look at the dizziness, but the inside of the SQL statement is relatively standard, if you use and want to clear the process, it will cost a little kung fu to change.
Have time to see abator this thing code how write, the best change, suitable for simple development is good