Home  >  Article  >  Java  >  JAVA database-based automatic generation tool, JavaBean, database documentation

JAVA database-based automatic generation tool, JavaBean, database documentation

怪我咯
怪我咯Original
2017-06-23 13:32:201629browse

                                TableGo v5.0.0 version update is shockingly released, the function is more powerful, come and watch quickly, this version update is as follows:
        1. The UI interface has been greatly revised, and the functional modules have been reorganized to meet the richer functions and designs in the future. .
2. Added Mapper mapping configuration files for batch generation of MyBaits.
3. Added the function of generating SQL based on database tables, which can automatically generate various SQL according to configuration.
    4. Modify and optimize to quickly generate JavaBeans based on fields, add field types and default types, etc.
5. Fixed the issue where JPA annotations generated by PostgreSQL sometimes make errors.
        6. Support database case-sensitive and table names and field names that contain both uppercase and lowercase letters.
7. Provide Jar package version, perfectly supporting Linux and MacBook.
8. Other bug modifications and code optimization adjustments.

There is another setting tip here, that is, when setting the entity generation strategy, it is best to choose no field validation, because I found that obtaining field validation data through JDBC is a bit slow and inefficient. Moreover, by configuring the naming strategy of Hibernate and MyBaits, the entity generation strategy can be set to "no Column annotations on all fields". This will generate JavaBeans the fastest and make future code maintenance much easier.

Hibernate or JPA Configuration: hibernate.ejb.naming_strategy = org.hibernate.cfg.improVEDNAMIMINGSTRATEGY

This configuration: MapundersCoreTocamelcase = TRUE (So after configuration, there is no need to write a resultMap field mapping in MAPPER.XML )
         
      The database driver package used by MySQL: mysql-connector-java-5.1.39.jar
    The database driver package used by Oracle: ojdbc14.jar
      The database driver package used by SQL Server: sqljdbc4.jar
The database driver package used by PostgreSQL: postgresql-9.4.1212.jre7.jar

has been automatically generating JavaBeans according to the database table structure, automatically generating MyBaits Mapper mapping configuration files, and automatically generating databases. Designing documents is a headache, a waste of time and cumbersome. Looking at tens of thousands of fields in dozens or hundreds of tables is really painful.
We have also thought of many ways to solve this problem, including using MyEclipse to connect to the database to generate JavaBeans, but there are still some unsatisfactory aspects, including the fact that comments for tables and table fields cannot always be generated, and there will be A lot of useless comment code is generated, which makes the code look unclean at all, and the configuration is very cumbersome, etc.
So out of anger, I started to make enough food and clothing by myself, so I wrote an automated database-based generation tool using Swing, which supports four databases: MySQL, Oracle, SQLServce, and PostgreSQL, and supports multiple operating systems such as Window, Linux, and MacBook. The system perfectly supports JPA annotations, can generate Entities and DTOs at the same time, can automatically remove table prefixes, and supports single and batch generation of JavaBeans. Now not only can comments be generated on member variables, but there can also be comments on Getters and Setters. More importantly, it can also automatically generate database design documents and MyBaits Mapper mapping configuration files. If there are multiple data sources, it can also be generated in batches, which is very convenient to use.
All configurations are saved locally. As long as they are configured once, the Mapper mapping configuration files and database design documents for JavaBeans and MyBaits can be generated in seconds the next time you use it. It also integrates various practical tools to make work more efficient. Instantly explode, productivity instantly explodes!
After using and accumulating some projects, I will share it. If you have any good suggestions and ideas, you can also put forward them. Because I am very busy and do not have time to do very comprehensive testing, there must be some bugs. Due to environmental reasons, the main tests are MySQL, Oracle, SQLServer, and PostgreSQL are not fully tested, and there may be some bugs. If you find any bugs, remember to tell me so that they can be corrected in the next version.

1. Database configuration interface:


2. Public parameter configuration interface:


3. Generate Bean configuration interface:

###4. Generate MyBaits Mapper mapping file configuration interface:


5. Generate database design document configuration interface:


6. Integrated tool interface, Integrating 11 practical tools, work efficiency is instantly improved several times:


7. Added the function of generating MyBaits Mapper mapping configuration file, and batch-generates Mapper.xml according to the current database configuration:




8. The function of batch generating database design documents can quickly generate databases in batches. Design documents. If a multi-thread processing timeout exception occurs when generating a document, you can avoid the timeout exception by increasing the multi-thread timeout and reducing the number of tables processed by each thread (modifying multi-thread parameters requires restarting the program). If the generated Word file If you can't open it with MS Office, you can open it with WPS and save it once, and then you can open it with MS Office. If you don't have WPS installed, you can also open it with WordPad, and then save it as a docx file. It is recommended to open or transfer it with WPS. , so that the file style will not be affected, and the ER diagram will be clearer. The Word file is generated with docx4j-3.3.1.jar:




9. Modify and optimize to quickly generate JavaBeans based on fields, add field types and default types, etc.:




##10. Added the function of generating SQL based on the database table, which can automatically generate various SQL according to the configuration to meet different needs:





11. This is the automatically generated Entity and DTO:




12. This The latest source code statistics:


13. Jar package version is provided, which perfectly supports Linux and MacBook. MacBook only needs to allow TableGo to be opened in "Security and Privacy". Jar will do:


## To use this tool, you need to install JDK7 and above, because the development environment and compilation environment currently used are JDK7. Other versions of JDK have not been tested. There should be no problem with higher versions. They must be included in the environment variables of the operating system. Configure JAVA_HOME, otherwise Java will not be found.

I have looked for a lot of tools to package Jar packages into EXE files, but none of them can perfectly support 64-bit systems. Finally, I found exe4j, which can finally perfectly support packaging into a version supported by 64-bit systems. I myself I am using the 64-bit Win10 system that comes with Alienware15R2. If the generated 32-bit program cannot run, please tell me and I will go find a virtual machine to test it.



The above is the detailed content of JAVA database-based automatic generation tool, JavaBean, database documentation. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn