MyEclipse Reverse engineering of Hibernate mode for entity classes generated from database

Source: Internet
Author: User

The steps are broadly as follows:
The first step :
window-->open perspective-->myeclipse Java persistence
A view appears after the operation DB brower:myeclipse Derby
Right-click in the blank area to create a new database object. I use MySQL, in fact, I always want to use Oracle and the like, but the machine memory is small, and lazy daoteng Other, the result of a screenshot:


Step Two:
Create a new web project
then select the project right-click-->myeclipse-->add Hibernate capabilities
If you need to add a comment to the entity class then select the Add Hibernate Annotations support next to it, which is said to be Annotations now!! )



 

then next select a directory to store automatically generated hibernate.cfg.xml files, generally without exception, placed in the SRC root directory, next select a DB driver in the first step we set up the one (for me is com.mysql ...). Anyway, that's the one you built, and then the next step is to select a directory to store the auto-generated Hibernatesessionfactory tool class, and then I looked at it. This hibernatesessionfactory tool class is a single instance of the session, and there are other ways to close the session, which is known at a glance. Is the generated configuration file:




The third step is to reverse the generation of entity classes
find the table to reverse in DB Brower Select and right-click--->hibernate Reverse enginnering

See options: Java src folder source package, do not explain, Java package--Store will be reversed entity class, select directory (should be built in advance Com.xxx.model such as package); Create pojo<>db ... With this option selected, we set up the configuration from the table to the simple Java object (that is, Pojo) and put the following add Hibernate mapping annotations to Pojo, and the other option is to "add map annotations to Pojo objects", The option above is used to create XML, which is said to be less useful, just use annotation!  


 


This should be enough, the next step.

look at the Picture: type mapping to choose Hibernatetypes, so these annotations are from javax.persistence.* (just watched!). )

ID Generator Look at the drop-down list to know is the configuration ID generation policy

that two enable is to say mapping relation discovery (detection), understand? Good English is dipping, do not like me still have to look up the dictionary.  


 

Next: There 's nothing to understand .






MyEclipse Reverse engineering of Hibernate mode for entity classes generated from database

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.