-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Ms-Sql SCOPE_IDENTITY error when update to 2.1.2
PostPosted: Fri Feb 06, 2004 11:00 pm 
Newbie

Joined: Mon Nov 17, 2003 11:04 am
Posts: 5
Hello,

I'm using MS-Sql 7.0 with jTDS 0.6 rc1.

Ok, I know that this is a not supported configuration but I get this error when update to 2.1.2 version, with hibernate 2.1.1 every works fine.

When I try to insert a new currency I get the following exception:

Code:
java.sql.SQLException: 'SCOPE_IDENTITY' is not a recognized function name.
    at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:85)
    at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:99)
    at net.sourceforge.jtds.jdbc.Tds.submitProcedure(Tds.java:609)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.submitProcedure(PreparedStatement_base.java:195)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(PreparedStatement_base.java:174)
    at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeQuery(PreparedStatement_base.java:210)
    at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:508)
    at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)


The currency mapping is:

Code:
<hibernate-mapping>
    <class
        name="com.giux.model.Currency"
        table="app_currencies"
        dynamic-update="false"
        dynamic-insert="false">

        <id
            name="id"
            column="id"
            type="java.lang.Long"
            unsaved-value="null">
            <generator class="native"></generator>
        </id>

        <property
            name="name"
            type="string"
            update="true"
            insert="true"
            column="name"
            not-null="true"
            unique="true"/>

        <property
            name="description"
            type="string"
            update="true"
            insert="true"
            column="description"
            not-null="true"
            unique="false"/>

    </class>

</hibernate-mapping>


Thanks, Claudio


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 07, 2004 12:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum
SCOPE_INDENTITY is only supported by SQLServer 2000

As a quick fix, remove
Code:
/**
  * Use <tt>insert table(...) values(...) select SCOPE_IDENTITY()</tt>
  *
  * @author <a href="mailto:jkristian@docent.com">John Kristian</a>
  */
  public String appendIdentitySelectToInsert(String insertSQL) {
      return insertSQL + " select SCOPE_IDENTITY()";
  }

from the SQLServerDialect class and I'll be fine I think.

I've added it to JIRA http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-694

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2004 4:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
SQL server 7 is not an officially supported platform. The dialect targets SQL Server 2000. (Of course, it is very easy to customize the dialect for use with 7.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.