[hibernate-issues] [Hibernate-JIRA] Created: (EJB-370) @GeneratedValue and id populated with function (MSSQL 2000)

Thierry Accart (JIRA) noreply at atlassian.com
Thu Jul 3 09:16:32 EDT 2008


@GeneratedValue and id populated with function (MSSQL 2000)
-----------------------------------------------------------

                 Key: EJB-370
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-370
             Project: Hibernate Entity Manager
          Issue Type: Bug
          Components: EntityManager
    Affects Versions: 3.2.1
         Environment: MSSQL 2000 server, ms sql 2000 jdbc driver, Hibernate EntityManager 3.2.1.GA, JBOSS 4.2.2 GA
            Reporter: Thierry Accart


When a table has its primary key (int id_ populated in SQL with IDENTITY, everything is fine.

Now, if you create a sql function getNextID()  that returns the next Id for this table, remove the identity setup for this column, and set getNextId() as default value, 
the entity manager seems to not catch the new value of ID.


in extenso : I created a new Entity
its ID is 0 in java.
I persisted it
-> when sql column was setup to Identity, the entitymanager retrieved the new id from SQL
-> when sql column was setup to be not null and have default value, the row was inserted in SQL (with the ID given by function call), but  the entitymanager did not retrieve the new ID from SQL, keeping 0 as id value.

Is it a normal behaviour, or should entityManager retrieve the new Id in any case ? 


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list