Software Version: mydomains6.5
Database: Oracle
Step 1: Create a database and a table
Use plsqldev to log on with system. Right-click the user to create a user and specify a role, as shown in figure 2 below.
Log On with the user name and password. Here we use a demo to create your own table.
Step 2: connect myeclips to the Oracle database.
Window --> open perspective --> myeclipse Java persistence
After the operation, a view dB Brower is displayed, right-click to create:
Finish,
Step 3:
Create a WEB Project
Right-click the project and choose --> myeclipse --> Add hibernate capabilities.
If you need to add comments to the object class, select the next enable hibernate annotations support (many enterprises use annotations)
Next, select a directory to store the automatically generated hibernate. cfg. xml file, which is usually stored in the SRC root directory without exception.
Next, select the created dB DRIVER:
Next, select a directory to store the automatically generated hibernatesessionfactory tool class (this can be canceled or not)
Finish, this hibernatesessionfactory tool class is a session Singleton, there are some other methods to close the session.
Step 4: reverse generate entity classes
Find the table to be reversed in dB Brower and right click ---> hibernate reverse enginnering
Option:
Java SRC folder source code package
Java package -- stores the entity classes to be reversed, and selects the directory (created by yourself ):
Generate non-annotation form: Click Finish. |
Annotation form: Select the Add hibernate mapping annotations to pojo option below. If you do not care about the other options, this option is used to "add the ing annotation to the pojo object ". Next, see Type Mapping should be selected with hibernatetypes, so these annotations are from javax. Persistence .*. Id generator: You can see from the drop-down list that the ID generation policy is configured. Enable indicates the discovery of ection) The next step is the default: Finish. |