Sapphight Hibernate in JBuilder9

zhaozj2021-02-16  50

(Original author: hotmanhh)

After mastering some concepts, it is relatively simple. Hoho, I will write it out in JBuilder9, and then write Tomcat, I feel more than the application on Apps Server. Step 1: Configure the Hibernate library to select Configure Libraries in the Tools on JB9, in User Home, a library, named hibernate2.1, add JAR file to this name, put the hibernate2.jar file first ADD, then Increase the hibernate / lib / all JAR files to this name, determine it. Step 2: Configure the JDBC library as follows, in fact, Hibernate comes with a JDBC library, but uses the JDBC library file corresponding to each database, this example is the Oracle's JDBC library file. Some netizens said, specified or not found JDBC drivers, Hibernate runtime reports. The reason why I analyzed is that the zip file is still less than JAR, ^ _ ^. My solution is to extract the classes12.zip file to a temporary directory, use the command line to enter the temporary directory, and execute the following command to reassign the library file. JAR CF CLASS12.JAR Javax Oracle can generate new classes12.jar files in this temporary directory. The NLS_Charset12.zip library file is the same. The interpretation of a netizen is as follows, "Actually the JAR file is a ZIP file containing meta-inf / manifest.mf." If you decide to do this, then do not choose the library file related to JDBC in the first step, ^ _ ^. Step 3: New project Don't tell me, you won't use JBuilder, if you won't use jbuilder, I have no way to teach you, you are so good, ^ _ ^. In the Properties in Project, add the library name in the ADD in the ADD under the Paths page tab. Step 4: Create your professional point of your lasting class, that is, create your Pojo. In fact, it is not so terrible, you will generate a bean and get started. Since it is Bean, it should comply with Bean's specifications, and provide the setter and getter methods. These are enough. You can generate bean's Properties and corresponding setter and getter methods, using the bean page tag in JB9 to complete this work is quite fast. Step 5: Fill in the mapping file for the long-lasting class, you should pay attention to a problem, and there is no clear mention of the official documentation. If you say, Hoho. According to the regulations, the map should be such a file name: persistent class name .hbm.xml. Please refer to the official first small example. After this step is finished, you archive, test, save. In fact, there is almost where it is almost because I specified where to find this map document in hibernate.cfg.xml. Then we'd better exist with the same directory in the same class. If you put it in the root directory, you will have one hundred lasting classes, you are dizzy, hoho, I am changing the wrong. Step 6: Fill in hibernate's profile hibernate.cfg.xml Where is this file, I am not a master, I don't want to shoot bricks, and ax is. I think it is placed in a class directory (including old profile hibernate.properties).

转载请注明原文地址:https://www.9cbs.com/read-19842.html

New Post(0)