[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6881) identity strategy AUTO uses SequenceStyleGenerator on mssql

andreas bleicher (JIRA) noreply at atlassian.com
Wed Dec 7 09:03:21 EST 2011


identity strategy AUTO uses SequenceStyleGenerator on mssql
-----------------------------------------------------------

                 Key: HHH-6881
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6881
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 4.0.0.CR2
         Environment: Hibernate 4.0.0.CR2, JBoss 7.0.2, MSSQL2008, JTDS-1.2.5
            Reporter: andreas bleicher
            Priority: Blocker


we are using identity generation with default strategy (GenerationType.AUTO) to support different DBMS (mssql, oracle, mysql)
our Id annotations:


{Code}
@Id
@GeneratedValue
public long getId()
{
   return id;
}
{Code}

since upgrading to jboss7/hibernate4 we get the following error on mssql when persisting a new entity:

14:33:10,373 ERROR [org.hibernate.id.enhanced.TableStructure] (http--127.0.0.1-8080-3) could not read a hi value: java.sql.SQLException: 
invalid object name 'hibernate_sequence'.


the reason is that instead of the IdentityGenerator the SequenceStyleGenerator is used although we are using the correct MSSQLServerDialect and it returns supportsIdentityColumns() = true. The SequenceStyleGenerator tries to find the 'hibernate_sequence' table which does not exist


workaround for mssql by changing code to:

{Code}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public long getId()
{
   return id;
}
{Code}


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list