I have been developing in one database with no problem. The configuration line is:
<property name="hibernate.connection.url">
jdbc:sqlserver://DEVD1;DatabaseName=myProject;SelectMethod=direct</property>
The sql statement generated always append the database name to the SQL query like this: myProject.dbo.<table name>
So, far no problem.
Now: I tried to point the mapping file to different instance for
testing. The new configuration file is like this:
<property name="hibernate.connection.url">jdbc:sqlserver://DEVD2;DatabaseName=myProjectTest;SelectMethod=direct</property>
Now, notice the difference. The database name changed to myProjectTest, and the sql server changed to DEVD2
When I try to connect to this database, I get a lot of errors because the generated SQL is not correct. Hibernate appends the old database name to the sql like this: myProject.dbo.<table name>, and it is supposed to be myProjectTest.dbl.<table name>
Consequently, all of my unit test fails.
I cleaned the project many times. I manually deleted the class files. I inspected the print out in the console, and hibernate reads from the correct file. I closed Eclipse to clean the cach. But, the problem is still there.
Anyone has ever seen anything like this?
Any idea where else should I look for?
Thanks