Oracle issue: ORA-00972: identifier is too long
Description
Environment
Attachments
Activity

Former user May 26, 2005 at 12:44 AM
Marking it as fixed, because nobody commented on this for a long time, so it must be working. Reopen if not.

PaulP March 14, 2005 at 2:50 PM
Please recheck with the current CVS codebase as this should have been fixed in the latest refactoring - can't help as I don't currently have Oracle set up.

MikeM November 29, 2004 at 9:27 AM
This is being caused when there is a <many-to-one> in the class being loaded and NHibernate puts a suffix on the identifier to ensure the column is uniquely identified in the results.
If there is no <many-to-one> (ie-no joined tables) then no suffix is added and the long column name is not too long because of the additional characters.
The properties are being Aliased and the identifier is not. If the identifier were aliased then it would work okay.

MikeM October 22, 2004 at 11:51 AM
Wow. Not sure I would have found that I'll dig into it to find out why adding a <many-to-one> would do that.
Thanks for finding a way to repro it.
Mike

Huan Huang October 22, 2004 at 10:29 AM
Now, I am able to reproduce this problem in NHibernate Unit test case. I added a new test case CriteriaTest.LongIdentifierTest and modified a little of Simple class/mapping and One Class/Mapping. The attached file is basically the source code of NHibernate tag alpha_0-3-0-0 checked out from cvs. The files modified are:
M src/NHibernate.DomainModel/Simple.cs
M src/NHibernate.DomainModel/One.hbm.xml
M src/NHibernate.DomainModel/Simple.hbm.xml
M src/NHibernate.Test/NHibernate.Test-1.1.csproj
M src/NHibernate.Test/App.config
M src/NHibernate.Test/CriteriaTest.cs
Looks to me, the error was caused by this part of the mapping:
<composite-id>^M
<key-many-to-one name="Key1" class="NHibernate.DomainModel.One, NHibernate.DomainModel" column="TOO_LONG_IDENTIFIERINORACLE92" />^M
<key-many-to-one name="Key2" class="NHibernate.DomainModel.One, NHibernate.DomainModel" column="simple_id_2" />^M
</composite-id>^M
<many-to-one name="One" class="NHibernate.DomainModel.One, NHibernate.DomainModel" column="one" />^M
composite-id followed by a many-to-one mapping. It's interesting, if you remove the many-to-one mapping it works fine.
Details
Details
Assignee

Reporter

I got this error when using Criteria Queries. The column of my table happen to be 29 characters, plus "_7" appended in the prepared SQL statement, it exceeds the maximum 30 characters for a Oracle identifier.
This error is not seen on HQL query.
However, when I try to reproduce the problem in NHibernate test case CriteriaTest.SimpleSelectTest, I found NHibernate handles it well. When the column name is very long, it's trimmed in the SQL statement. For example,
<property name="Address" type="String" length="200" column="addressaddressaddressaddressa" />
I changed the column name of Simple.Address to 29 characters,but in the SQL, it appears :
2004-10-21 10:56:27,759 [3816] INFO NHibernate.Impl.BatcherImpl [] <> - Preparing select simple0_.id_ as id_, simple0_.Name as Name, simple0_.addressaddressaddressaddressa as addressa3_, simple0_.PD_PREDECESSOR_PROJECT_ID_FLE as PD_PREDE4_, simple0_.date_ as date_, simple0_.Other as Other from Simple simple0_
I have more than 40 tables mapped, and they are highly associated each other, so, I really hesitate to post all the mapping files and my source code to here. I think it's very likely that this error take place when one-to-many many-to-one mapping exists between objects, and the column name is very long.