lundi 30 mars 2015

Invalid object name 'tableName' using Hibernate and Spring, with SQLServer

I am stuck on this for days, and I have tried almost everything that I have found on the internet. I am building web application, using Spring and Hibernate in Java, and I have two databases in SQLServer that I am trying to connect with application. One works perfectly, but I can not get data from another, although the configurations for both databases are exactly the same (the URL and user are different, of course).


Here are my code for database connection, entity class and DAOImplementation:


Database connection:



jdbc.driverClassName = com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url = jdbc:http://sqlserverxxx.xxx.xxx.xxx:xxxx;databaseName=Alti2009_DataLab
jdbc.username = xxxxx
jdbc.password = xxxxx
hibernate.dialect = org.hibernate.dialect.SQLServer2008Dialect
hibernate.show_sql = true
hibernate.format_sql = true
hibernate.default_schema = dbo


Part of DAO:



@Override
@SuppressWarnings("unchecked")
public List<Test1> testList() {
Criteria criteria = getSessionErp().createCriteria(Test1.class);
List<Test1> list = (List<Test1>) criteria.list();
return list;
}


Entity class:



@Entity
@Table(name = "test1")
public class Test1 implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;

@Column(name = "name", nullable = false)
private String name;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return "Test1{" + "name=" + name + '}';
}

}


Any help will be very appreciated, because I do not know what to do next.


Aucun commentaire:

Enregistrer un commentaire