Problem using Hibernate and SQL Server 2008

后端 未结 3 430
谎友^
谎友^ 2021-01-19 06:34

I\'m having problems using Hibernate and SQL Server 2008. When I try to save an object to database Hibernate throws this:

could not retrieve snapshot: com.my         


        
相关标签:
3条回答
  • 2021-01-19 07:16

    Change the schema to dbo. In SQL Server, schema is a container in the database, not the database itself. This may be different in MySQL, but in this case, your schema should be dbo (based on your comment about it working if you add "dbo." to your resultant query.

    Thanks, Eric

    0 讨论(0)
  • 2021-01-19 07:21

    So is there any other Hibernate configuration I need to make?

    With your current setup, I guess you'll have to specify the schema. For example, in the mapping:

    <class name="Users" table="Users" schema="dbo" catalog="suiteaccess">
    

    But you can also specify the default schema using the hibernate.default_schema property (see 3.4. Optional configuration properties).

    Just in case, you can create your own schema.

    0 讨论(0)
  • 2021-01-19 07:27

    Put below configuration into mapping file. It resolved the Invalid object exception.

    <class name="Users" table="databaseName.dbo.Users">
    

    Change the above line into Mapping file. It should be work. Because Mssql server have default schema (dbo). That's why use the fully classified table name.

    0 讨论(0)
提交回复
热议问题