How the Java generated entity classes are implemented inside the tool (MySQL)

Source: Internet
Author: User

I. Knowledge of the INFORMATION_SCHEMA database

INFORMATION_SCHEMA database provides a way to access database metadata (data)

The database contains various data such as database name, table name, column name, column data type, etc.

Generating entity classes starts with the database

Ii. displaying all the databases

To generate the entity class, it is very easy to select the database first, this is simply a simple sentence of SQL to get all the database

show databases;
Third, using the tables table to get the table in the database

Next, to display all the tables for the selected database, here is the INFORMATION_SCHEMA database that was mentioned earlier

The tables table below it holds the structure of each table data and table we have created.

Here we only take the name of the table, where DatabaseName is the database name chosen

SELECT  from WHERE = ' DBName '
Iv. using the columns table to get the fields and other data in the table

When you select a table, you get the fields in the table, field data types, comments, and so on, regardless of what you choose to generate.

This information can be found in the columns in the INFORMATION_SCHEMA database, as in sql:

SELECT DISTINCT  from WHERE = ' TableName '  and = ' DBName '

which

column_name
Field name
Data_type
field data type
Field Comment
Column_key
Whether it is a primary key, foreign key, unique index, etc.
V. Using the resulting data to splice the generated code

Here a little

How the Java generated entity classes are implemented inside the tool (MySQL)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.