Use myeclipse to generate the hibernate Mapping File

Source: Internet
Author: User

Use myeclipse to generate the hibernate Mapping File
Keyword: hibernate
In hibernate, each data table corresponds to an entity class, and each entity class has a corresponding HBM. the xml configuration file matches you. myeclipse actually has a myeclipse Database Explorer view, which provides a built-in window for direct connection between myeclipse and the database, and through which you can generate a hibernate Mapping File.
 

1. Right-click the project and select the myeclipse option to add the hibernate feature to the application.

2. In the displayed Configuration window, select "add hibernate 2.1 libraries to project ?", Then set the directory to store the hibernate library file:/WEB-INF/lib directory, default will choose to create a new hibernate configuration file hibernate. cfg. xml.

3. click Next To Go To The Hibernate database connection configuration page. In the connection profile option, select vipdata option configured in myeclipse Database Explorer, and other configurations will be automatically generated, you can select copy JDBC driver and add to classpath to copy the JDBC driver to the WEB-INF/lib directory. :

4. Click Next to create the sessionfactory class of hibernate. This is a simple factory class for centralized management of hibernate sessions. Enter the full name of the class.

5. Click Finish. Then, myeclipse will copy the hibernate-related jar package to the lib directory, and generate the hibernate configuration file: hibernate. cfg. XML, and sessionfactory.

Now we need to use tools in the myeclipse Database Explorer view to generate the hibernate ing file. Switch to the myeclipse Database Explorer view, right-click the vipdata table, and select create hibernate mapping.

6. Configure the generated persistence class and ing file.

7. Click Browse and select the generated class and ing file package: COM. xxx

8. ID GeneratorAlgorithmSelect native. (There are many other options available. You can choose one based on your application requirements. It seems that the hibernate ing table must have master keys; otherwise, the hibernate technology cannot be used ).

9. click Finish. This will generate the persistence vipdata class and its parent class abstractvipdata (generate the parent class for future application extension. The tool will automatically generate the detailed equals method and hashcode method) and the ing file XXX. HBM. XML. At the same time, the hibernate configuration file hibernate. cfg. XML will be modified, and a line will be added.

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.