History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: HHH-3231
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Steve Ebersole
Reporter: Király Attila
Votes: 2
Watchers: 3
Operations

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

org.hibernate.id.enhanced.TableGenerator throws "IllegalArgumentException: alias not found: tbl" under Oracle

Created: 12/Apr/08 10:03 AM   Updated: 01/Oct/08 03:04 AM
Component/s: core
Affects Version/s: 3.2.6
Fix Version/s: 3.4, 3.2.x, 3.3.1

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive hibernate_etg_ora.zip (2.80 Mb)

Environment: Hibernate 3.2.6GA, Oracle 10g

Requires Release Note: Affirmative


 Description  « Hide
org.hibernate.id.enhanced.TableGenerator always throws the following exception if I want to save a new object to Oracle:
java.lang.IllegalArgumentException: alias not found: tbl
at org.hibernate.sql.ForUpdateFragment.<init>(ForUpdateFragment.java:36)
at org.hibernate.dialect.Dialect.applyLocksToSql(Dialect.java:970)
at org.hibernate.id.enhanced.TableGenerator.configure(TableGenerator.java:194)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:104)

I attach an example to this case. The example is loosely based on the tutorial example, that comes with Hibernate. It contains a Person object that is saved to db using the enhanced.TableGenerator as id generator. To keep the zip small only the jars of jdbc driver are included, the jars needed from hibernate distribution are listed in lib/readme.txt.

The zip also contains a modified TableGenerator that works with Oracle. This version was made by forum user stomp and more information about it can be read here: http://forum.hibernate.org/viewtopic.php?t=980933
It changes the 194th row of TableGenerator from
this.query = dialect.applyLocksToSql( query, lockMap, CollectionHelper.EMPTY_MAP );
to
this.query = dialect.applyLocksToSql( query, lockMap, Collections.singletonMap("tbl", new String[] {valueColumnName}) );

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
TJ Moretto - 03/Jun/08 06:42 PM
For whatever reason I only experience this issue when using an hbm file to map an entity class. Using the javax.persistence annotations works fine:

    @GeneratedValue(strategy=GenerationType.TABLE)
    @TableGenerator(name="mytable")

Steve Ebersole - 28/Aug/08 09:00 AM
This is actually an issue when using any Dialect which reports that it supports "for update of columns", the Oracle dialects being examples of this.

Emmanuel could say more definitively, but I believe that @TableGenerator does not map to the enhanced table generator.

Prakash - 29/Sep/08 12:48 PM
I am still having the same problem with latest build 3.3.1. We are trying to implement TableGenerator for SQL Server and Oracle both. The configuration works well for SQL Server, but not for Oracle. Is this issue really fixed?


Exception in thread "main" org.hibernate.MappingException: could not instantiate id generator
        at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:98)
        at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:192)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
        at managers.HibernateManager.createSessionFactory(HibernateManager.java:42)
        at hibernate.checkHibernate.<init>(checkHibernate.java:35)
        at hibernate.Main.startHibernate(Main.java:80)
        at hibernate.Main.main(Main.java:61)
Caused by: java.lang.IllegalArgumentException: alias not found: tbl
        at org.hibernate.sql.ForUpdateFragment.<init>(ForUpdateFragment.java:36)
        at org.hibernate.dialect.Dialect.applyLocksToSql(Dialect.java:970)
        at org.hibernate.id.enhanced.TableGenerator.configure(TableGenerator.java:194)
        at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:94)
        ... 7 more
Java Result: 1

Király Attila - 30/Sep/08 04:55 AM
@Prakash
Are you sure that you are using the 3.3.1 version of hibernate core?
Your exception is the same as my was with 3.2.6 (before the fix). The exception says
        at org.hibernate.id.enhanced.TableGenerator.configure(TableGenerator.java:194)
Checking the sourcecode of o.h.id.enhanced.TableGenerator this function name and row number is correct in 3.2.6 but it has changed in 3.3.1 (configure is between rows 279 - 299 now).

Prakash - 30/Sep/08 11:03 AM
Yes, I downloaded the distribution from http://sourceforge.net/project/showfiles.php?group_id=40712&package_id=127784&release_id=625684 and change log does mention 3.3.1.GA (2008.09.10)

May be the changes are not available in build available to download?

Prakash - 30/Sep/08 04:00 PM
It was my bad. The project was using wrong library. Sorry about that and thank you for responding.