错误提示1:Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [com.qpxnet.entityDAO.Contacts#527]
错误提示2:Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '.200'.我的映射文件 <class name="com.qpxnet.entityDAO.Contacts" table="200_Contacts" schema="dbo" catalog="Restart">
请问这里table="200_Contacts"是不是不能以数字打头?可是我的表不可能再改了,有解决办法吗?如果不是那里错,那又是哪里错了呢?请指出,告诉解决办法,万分感谢。
错误提示2:Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '.200'.我的映射文件 <class name="com.qpxnet.entityDAO.Contacts" table="200_Contacts" schema="dbo" catalog="Restart">
请问这里table="200_Contacts"是不是不能以数字打头?可是我的表不可能再改了,有解决办法吗?如果不是那里错,那又是哪里错了呢?请指出,告诉解决办法,万分感谢。
先猜测下:
1. 你的hbm没有配好
2. 你是不是用HQL查询的,“'.200'”, 200前面有个点,估计是HQL没写好。表名的规范是数据库规定的,Hibernate不会有特殊要求的吧
log.debug("getting Contacts instance with id: " + id);
try {
System.out.println("@@@@@@@@@@"+id);//打印成功
Contacts instance = (Contacts) getHibernateTemplate()
.get("com.qpxnet.entityDAO.Contacts", id);
System.out.println("************"+id);//打印不成功
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}映射文件:
<class name="com.qpxnet.entityDAO.Contacts" table="200_Contacts" schema="dbo" catalog="Restart">
<id name="idContact" type="java.lang.Integer">
<column name="id_contact" />
<generator class="native" />
</id>
<property name="contType" type="java.lang.Integer">
<column name="Cont_Type" />
</property>
。。
.get("com.qpxnet.entityDAO.Contacts", id);
"com.qpxnet.entityDAO.Contacts" -->修改成Contacts.class或者com.qpxnet.entityDAO.Contacts.class
双引号坚决的不要