Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The configuration process of using annotations instead of entity mapping hbm.xml files in SSH integration

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "the configuration process of using annotations instead of entity mapping hbm.xml files in SSH integration". In daily operation, it is believed that many people have doubts about the configuration process of using annotations instead of entity mapping hbm.xml files in SSH integration. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful for you to answer the question of "using annotations instead of the configuration process of entity mapping hbm.xml files when SSH integration"! Next, please follow the editor to study!

In the most primitive ssh development, Hibernate needs to configure hbm.xml entity mapping files, which is extremely troublesome when there are many tables and complex table relationships.

Now it is common to replace the original configuration with the configured comments in the JAR package:

In the beans.xml configuration file (applicationContext.xml)

Cw/test/bean/Employee.hbm.xml

Delete the mapping and change it to:

Cw.test.bean.Employee

Where cw.test.bean.Employee is the entity class

Change the specific entity class to the following form and add comments:

@ Entity@Table (name= employee) public class Employee implements java.io.Serializable {@ Id@Column (name= "username") private String username;@Column (name= "password") private String password;@Enumerated (EnumType.STRING) private Gender gender = Gender.MAN;public Employee () {} public Employee (String username, String password) {this.username = username;this.password = password;} public String getUsername () {return username;} public void setUsername (String username) {this.username = username;} public String getPassword () {return password } public void setPassword (String password) {this.password = password;} public Gender getGender () {return gender;} public void setGender (Gender gender) {this.gender = gender;}}

It is important to note that if a field is of an enumerated type, you need to use the Enumerated annotation and implement the java.io.Serializable class on the entity class.

At this point, the study on "the configuration process of using annotations instead of entity mapping hbm.xml files when SSH integration" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report