Issue Details (XML | Word | Printable)

Key: HHH-2301
Type: Patch Patch
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Steve Ebersole
Reporter: Scott Rankin
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

Identity generator with custom insert SQL broken in 3.2 (Scott Rankin and Gail Badner)

Created: 11/Dec/06 02:57 PM   Updated: 08/May/07 05:04 PM   Resolved: 08/May/07 05:04 PM
Component/s: core
Affects Version/s: 3.2.1
Fix Version/s: 3.2.4

Time Tracking:
Not Specified

File Attachments: 1. Text File AbstractEntityPersister.patch (1.0 kB)
2. Text File HHH-2301-new-testcase.patch (13 kB)
3. Text File HHH-2301-testcase.patch (10 kB)

Environment: JDK 1.5.0_08, Windows XP

Patch Reminder (view):
REMINDER: Patches should be in 'svn diff' format; see details
Participants: Gail Badner, Max Rydahl Andersen, Scott Rankin and Steve Ebersole


 Description  « Hide

When an entity is defined as having custom insert sql and has a ID generator strategy of "identity", the custom insert SQL is ignored in 3.2. This previously worked in 3.1.3.

More details on the forum here: http://forum.hibernate.org/viewtopic.php?t=966317



Scott Rankin added a comment - 11/Dec/06 04:29 PM

This patch restores the behavior of 3.1.3 by checking to see if custom insert SQL has been defined and if so, using it instead of the generated SQL.


Gail Badner added a comment - 30/Mar/07 06:51 PM

I have attached a patch for a MySQL-specific unit test, MySQLWithNativeGeneratedIdsTest, that reproduces this issue. It is the same as org.hibernate.test.sql.MySQLTest except its mapping file uses native-generated (auto-increment) IDs. I've add it to the test suite in org.hibernate.test.sql.MySQLWithNativeGeneratedIdsTest.

I have also verified that AbstractEntityPersister.patch fixes this issue and does not cause any other unit tests to fail.

Gail Badner
SourceLabs - http://www.sourcelabs.com
Dependable Open Source Systems


Gail Badner added a comment - 11/Apr/07 03:22 PM

I have attached a patch for a new test case, HHH-2301-new-testcase.patch, that reproduces this issue for both Hypersonic and MySQL.

I've created this new test case, CustomSQLWithNativeGeneratedIdsTest, so that it will execute using the default dialect (HQLDialect). This test case extends HandSQLTest. The mapping for this test case is the same as MySQLEmployment.hbm.xml except that the native ID generator (identity) is used and it only includes those definitions used by HandSQLTest.testHandSQL().

I moved the methods in HandSQLTest that dealt with stored procedures into HandSQLWithStoredProcsTest and changed Db2SQLTest, MSSQLTest, MySQLTest, DataDirectOracleSQLTest, and OracleSQLTest to extend HandSQLWithStoredProcsTest. I did this for several reasons. I thought it best if this test run by default with HSQLDialect. Since Hypersonic stored procedures are more complicated (they must be written in Java and made accessible to the DB server), and because I felt that HandSQLTest.testHandSQL() was sufficient to test this issue, I decided that implementing this test using stored procedures was not worthwhile.

The first patch (HHH-2301-testcase.patch) can still be used with MySQL if anyone decides it is worthwhile to test using stored procedures.

Gail Badner
SourceLabs - http://www.sourcelabs.com
Dependable Open Source Systems


Max Rydahl Andersen added a comment - 18/Apr/07 03:19 AM

fix looks trivial; lets include it for the next version.


Max Rydahl Andersen added a comment - 18/Apr/07 05:09 AM

note: I haven't looked at the testcases from Gail - just the patch.


Steve Ebersole added a comment - 08/May/07 04:09 PM

Well, I checked Gail's testcases. Great work as usual Gail

I did make one minor change to your CustomSQLWithNativeGeneratedIdsTest class. You had it extending from the HandSQLTest stuff. I changed it to extend from the more generic DatabaseSpecificFunctionalTestCase. I then applied this test to all dialects which support IDENTITY columns. I then mapped just one entity (Organization) in the corresponding mapping, with a PK using the identity generator. I also added your name as author on your work.

I also took this opporunity to clean up this series of tests a little bit.


Steve Ebersole added a comment - 08/May/07 05:04 PM

trunk / 3.2