Hibernate 无效的对象名称hiberate 3.6

Hibernate 无效的对象名称hiberate 3.6,hibernate,jakarta-ee,orm,Hibernate,Jakarta Ee,Orm,在我的应用程序中,我不断收到一个连接到托管SQL Server 2008的“无效对象名”。我可以使用字符串从应用程序中查询数据库。但是,每当我使用Hibernate时,就会出现这个错误 //Calling Class SessionFactory sf = new Configuration().configure().buildSessionFactory(); Session session = sf.openSession(); Transaction tx = session.begin

在我的应用程序中,我不断收到一个连接到托管SQL Server 2008的“无效对象名”。我可以使用字符串从应用程序中查询数据库。但是,每当我使用Hibernate时,就会出现这个错误

//Calling Class
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Transaction tx = session.beginTransaction();
session.save(survey);
tx.commit(); <!--Blows up-->
session.close();


<hibernate-configuration>
<session-factory name="Persist">
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.password">xxxx</property>
<property name="hibernate.connection.url">jdbc:sqlserver://xxxx</property>
<property name="hibernate.connection.username">xxxx</property>
<property name="hibernate.default_catalog">xxxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</property>
<mapping class="com.springmvc.dao.Survey" resource="com/springmvc/dao/Survey.hbm.xml"/>
</session-factory>
</hibernate-configuration>

//Table Mapping
<hibernate-mapping>
<class name="com.springmvc.dao.Survey" table="Survey">
    <id name="SurveyId" type="int">
        <column name="SURVEYID" />
        <generator class="assigned" />
    </id>
    <property name="SurveyName" type="java.lang.String">
        <column name="SURVEYNAME" />
    </property>
    <property name="CreateDate" type="java.sql.Date">
        <column name="CREATEDATE" />
    </property>
    <property name="IsActive" type="boolean">
        <column name="ISACTIVE" />
    </property>
</class>
</hibernate-mapping>

//The Error
org.hibernate.exception.SQLGrammarException: could not insert: [com.springmvc.dao.Survey]
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'Recruiter.Survey'.
//调用类
SessionFactory sf=新配置().configure().buildSessionFactory();
Session Session=sf.openSession();
事务tx=会话.beginTransaction();
保存(调查);
tx.commit();
session.close();
com.microsoft.sqlserver.jdbc.SQLServerDriver
xxxx
jdbc:sqlserver://xxxx
xxxx
xxxx
org.hibernate.dialogue.sqlserver2008dialogue
//表映射
//错误
org.hibernate.exception.sqlgrammareexception:无法插入:[com.springmvc.dao.Survey]
由以下原因引起:com.microsoft.sqlserver.jdbc.SQLServerException:无效的对象名称“Recruiter.Survey”。

谁能告诉我发生了什么以及如何修复它,这一定是一个休眠问题。我试图添加一个方案,但出现了一个错误,说明Recruiter.dbo.Survey是不允许的。没有更多的配置文件可供查看,谷歌为我提供了任何有用的东西。谢谢

您的主键SurveryId将生成器类设置为“已分配”,您需要在调用Save in hibernate会话之前分配密钥。你在这么做吗?如果你不想生成,那么让它自动生成