Hibernate--hibernate.cfg.xml Configuration

Source: Internet
Author: User

Database connection <required>:
<property name= "hibernate.connection.driver_class" >
Com.mysql.jdbc.Driver
</property>
<property name= "hibernate.connection.username" >root</property>
<property name= "hibernate.connection.password" >root</property>
<property name= "hibernate.connection.url" >
Jdbc:mysql://localhost:3306/db_name
</property>
Dialect <required>:
<!--database dialect: Specify the database to which you want to connect, or you cannot build the table-
<!--hibernate5.0 MySQL5--
<!--hibernate5.1 Mysql5innodbdialect--

<property name= "hibernate.dialect" >
Org.hibernate.dialect.MySQL5InnoDBDialect
</property>
SQL Display Method:
<!--whether to show SQL--
<property name= "hibernate.show_sql" >true</property>
<!--whether to format SQL--
<property name= "hibernate.format_sql" >true</property>
<!--If you need to maintain table structure--
<property name= "hibernate.hbm2ddl.auto" >update</property>
Update: The table is not created, and if the table has changed, the incremental modification
    Based on the original table to modify, the original table data will not be deleted
Create: Deletes the old table every time, creating a new table
    Re-creating the database table structure each time you reload hibernate may result in data loss
Create-drop: Create first, delete the table after the test is complete
Validate: Validation does not automatically generate tables, each time the database is started verifies that the tables and entities in the database are consistent, if inconsistent, error
mapping information <required>:
<!--mapping file--><mapping resource= "Com/roxy/hibernate/pojo/customer.hbm.xml"/>

Hibernate--hibernate.cfg.xml Configuration

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.