A project was previously deployed in Wuhan and deployed in Nanjing. Because it is in line with others to do, the database is built by others to complete, we are only responsible for the database of several tables of data processing. The previous database name is Projectwh, when the deployment of Nanjing, the beginning is also used by the name of the Projectwh, later the other party re-created a database Projectnj (Projectwh not deleted), We have modified the database name in the URL in the Hibernate configuration file to Projectnj, but the target of the discovery access operation will still be the table in the Projectwh.
Generally want to hibernate in the configuration file should only the URL and database name related AH? How can this problem arise. Finally, the global search PROJECTNJ only found that the original corresponding table in the Hibernate mapping file also indicates which database the table belongs to, that is, Hibernate is not based on the database name in the URL to determine the specific use of which database, When two databases are very similar (user name and password), if the database name in the mapping file is incorrectly written, the program will write the data in the corresponding database table in the mapping file. Since mapping files are generally generated automatically, it is very rare to pay attention to this problem.
In summary, when the table that discovers the program action is inconsistent with the table in the expected database, not only to check the URL configuration, but also to check the mapping file of the corresponding table.
Database name error problem in hibernate database configuration file