Original: IntelliJ idea 13.x using hibernate + Spring MVC + JBoss 7.1.1
Starting from 2004. NET up to now. Until recently to do some Java project, if say 100 people write an article about. NET article, it is estimated that the 10 people write the same content. But if 10 people write a Java article, it is really 10 people 10 kinds of writing. This is the most difficult place to start learning is really confused.
Here we are using Hibernate 4.x + Spring MVC 3.x
1. To build a spring MVC project, the first thing to do is add Project Facets, we'll add a hibernate, and then add a hibernate Configuration, That's hibernate.cfg.xml.
2. Add a Resources folder and mark it as the resources root, in which we want to put the generated <classname>.hbm.xml
3. View->tool windows-> Persistence, find this hibernatetest->new->session Factory (here we don't use sessionfactory beans first )
4. Create a Hibernate.cfg.xml file, and we'll put him in the resources folder for the time being. After the build, this configuration XML is still empty, next we will build the configuration
5. Or right-click Hibernatetest->generate persistence mapping->by Database Schema
6. Select the table you want to generate class and HBM, for example we only select one hellotable
7. After the generation is like this, when you want the console to hibernate hql query, he will error, (Do not know why ...) Knowing that the deploy succeeds, the query is normal again)
8. We need to modify the location of the Hibernate.cfg.xml file and the location of the HBM files.
First we need to move the Hibernate.cfg.xml file to the src/.
Second, all the previously generated HBM files are together with class, and now we want to move all the generated HBM files to the Resources folder
9. Open a controller and write a code to insert the database
10. Re-check the settings of the artifacts.
11. Deploy to JBoss
Complete. Code download
IntelliJ idea 13.x using hibernate + Spring MVC + JBoss 7.1.1