In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to generate Hibernate Mapping files, which are very detailed and have certain reference value. Friends who are interested must finish reading them.
We all know that in hibernate, each data table actually corresponds to an entity class, and each entity class has a corresponding hbm.xml configuration file that matches you. In fact, there is a MyEclipse Database Explorer view in myeclipse, which provides a built-in window for myeclipse to connect directly to the database, and through this window you can generate hibernate mapping files.
1. Right-click on the project and select the MyEclipse option to add Hibernate features to the application.
two。 In the configuration window that appears, select "Add Hibernate 2.1 libraries to project?", and then set the directory where the Hibernate library files are stored to: / WEB-INF/lib directory, and a new Hibernate configuration file hibernate.cfg.xml will be created by default.
3. Click next to enter the Hibernate database connection configuration interface, directly select the vipdata option configured in MyEclipse Database Explorer in the Connection Profile options, and then other configurations will be automatically generated. You can select "Copy JDBC Driver and add to classpath" so that the JDBC driver will be copied to the WEB-INF/lib directory. :
4. Click next to create the SessionFactory class for Hibernate, a simple factory class that centrally manages Hibernate sessions, filling in the full name of the class.
5. Click finish, and MyEclipse will copy the Hibernate-related jar package to the lib directory, and generate Hibernate configuration files: hibernate.cfg.xml, and SessionFactory classes.
Now you need to use the tools in the MyEclipse Database Explorer view to generate the mapping file for Hibernate. Switch to the MyEclipse Database Explorer view, right-click on the table vipdata, and select Create Hibernate Mapping.
6. Configure the generated persistence classes and mapping files.
7. Click Browse, and select the package of the generated class and mapping file: com.xxx
8.ID Generator algorithm option, select native. There are many other options to choose from, depending on the needs of the application, as if the tables mapped by hibernate must have a master key, otherwise you can't take advantage of hibernate technology.
9. Click finish, which will generate the persistent class Vipdata and its parent class AbstractVipdata (generate the parent class, which is conducive to future application extensions, and the tool will automatically generate detailed equals and hashCode methods) as well as the mapping file xxx.hbm.xml. At the same time, the configuration file hibernate.cfg.xml of Hibernate will be modified to add a line.
At this point, the Hibernate mapping file generation is complete. :)
The above is all the contents of the article "how to generate Hibernate Mapping files". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.