Using Eclipse to generate entity classes and mapping files through a connection database __eclipse

Source: Internet
Author: User

Isin theHibernatein theIn the projectof theThe application is more and more extensive. I started studying it after I started to support annotation syntax from hibernate.of the。 Say Realin the of theOriginallyof theHibernate generationof theA heap of pilesof theThe XML file looks dizzy, and it's better to write it yourself.of theSQL statement toof theComfortable, so keep listening to friendsandColleagues introduced, but they have been dismissive of the use of it.
But nowin theBlessed Hibernate is the most commonly used in JPAof theImplementation, and Hiberante itself also supports annotation syntax. Isin theI don't need to see that pile of crap.of theXML map. And Eclipse also provides the direct generation of entity Class from the databaseof theTools. Since you can write less or do not write SQL statements that happy and for it.         Cut the crap and start doing it. Or are we starting with the project?of theThe first step is to start a new project. In general, we use Java to do Web projects are file->new->dynamic Web project, the following figure:

The new project will then appearof thedialog box as shown in the picture

Then click the Modify button as shown

Select the Java persistence to add JPA for the projectof theFeatures, other features are modified to suit the needs of the project. Click OK. Click a few times next (ignoreof theA few steps, depending on your situation, to the JPA facet window, as shown below:


Because we useof theIs hibernate the list is not so platform select Generic,type Select Disable Library configuration because we put the needof theThe jar file is placed directly under Web-infof theLib Directory is ok. So no configuration. and below.of theConnection this is necessary to configureof theHow else do we get from the databaseBuild inAh. Yes, No.
If you have previously configured a direct selection of the connection, if you have not configured the Click Add Connection the following figure:

Select to useof theDatabase type, and then next, the following figure. Actually, this type has no effect. Just a build connection stringof theTemplate and to.

Select an existingof theDrive, if not what to do, nonsense, of course, is continue to add. This piece is not detailed, click the first button behind the driver, according to the prompts to select the correspondingof theJar file.
Click Finish to finish the above operation. Back to the JPA facet window. Select Discover annotated classes automatically, the Create Orm.xml fishing. Then the finish project was completed.
And thenin theRight-click on the project folder to select JPA tools->generate entities from Tables. The following figure:

Choose to build a goodof theConnection Connect If there is no connect. As shown in the above picture (sometimes eclipse will have some small problems to see the table, you can restart the test, realin theNo, just build a JPA project, build the entity, and then handcuff yourselfof theThe project is ready. ) to select the entity to generateof theTable, next to the following figure:

The top is between the tablesof theRelationship, if it can be done accordinglyof theModify (withof theIt's ecipse 3.5. It looks like eclipse3.4 hasn't had this feature yet, Eclipse is getting stronger, and then next, the following figure:

(This seems to be Eclipse 3.5 plusof the) can see it. Change according to need to change, here is not much verbose. And then next.
After the following figure:

Here are some tablesof theEach propertyof theAdjustment, generally do not need to tune. Finish the job.
Hey, it's finally done. I'm tired of sticking up so many pictures. But for everyone to understand, or the picture more than the words can explain the situation, I work hard to point it.
Look at the sourceBuild in of theJava file is not what you wantof the, and how to use these kinds of concrete. That's not what this article is about.of theThe problem. If you need anything, I'll write next time.

Related Article

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.