Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 262923 - Aliased column names result in ORA-00972
Summary: Aliased column names result in ORA-00972
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: submitted_patch
Keywords:
: 294971 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-01-29 11:47 EST by Drew CLA
Modified: 2022-06-09 10:31 EDT (History)
10 users (show)

See Also:


Attachments
Limit alias name length to Platform maximum field length - Eclipse 1.0.2 patch (3.83 KB, patch)
2009-05-01 17:38 EDT, Mike Kienenberger CLA
peter.krogh: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Drew CLA 2009-01-29 11:47:07 EST
When executing a query which has had setMaxResults set on it, column names are aliased and when the column name is already very long the alias will exceed 30 characters, causing the ORA-00972 error.

As an example, in my situation one of the columns is named 'max_price_patient_split_copay' which is 30 characters.  When the query is generated this is aliased as follows: 'max_price_patient_split_copay AS max_price_patient_split_copay56'.

This bug can be reproduced by using any column name that is already 30 characters and then executing a query like this:

entityManager.createQuery("SELECT t FROM Test t").setMaxResults(10).getResultList();
Comment 1 Michael OBrien CLA 2009-01-29 11:56:32 EST
See additional example of the ORA-00972 30 char limitation in our JPA example code which usually shows up first in the @SequenceGenerator names - because they tend to be larger supersets of the column names.

http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/ejbModule/org/eclipse/persistence/example/jpa/server/business/Cell.java


    @Id
    // keep the sequence column name under 30 chars to avoid an ORA-00972   
    @SequenceGenerator(name="EL_SEQUENCE_CELL", sequenceName="EL_CELL_SEQ", allocationSize=25)
    @GeneratedValue(generator="EL_SEQUENCE_CELL")
    private BigInteger id;

Comment 2 Tom Ware CLA 2009-02-04 12:58:59 EST
Setting target to 1.1X so this bug will be a candidate for the first patch release after 1.1
Comment 3 Michael OBrien CLA 2009-02-16 02:23:09 EST
7337866
Comment 4 Michael OBrien CLA 2009-02-18 14:28:04 EST
*** Bug 241919 has been marked as a duplicate of this bug. ***
Comment 5 Mike Kienenberger CLA 2009-02-18 15:54:13 EST
Example implementation of the workaround proposed in Bug 241919 which is working for me:

public class MySessionCustomizer implements SessionCustomizer {
	public MySessionCustomizer () { }

	public void customize(Session session) throws Exception  {
            // TODO: temporary workaround for EclipseLink bug 262923 & 241919
            Platform datasourcePlatform = session.getDatasourcePlatform();
            OraclePlatform oraclePlatform = (OraclePlatform)datasourcePlatform;
            oraclePlatform.setShouldUseRownumFiltering(false);
	}
}


In persistence.xml:

[...]
        <properties>
[...]
			<property
			    name="eclipselink.session.customizer"
			    value="mypackage.MySessionCustomizer "/>



Comment 6 Mike Kienenberger CLA 2009-05-01 17:38:05 EDT
Created attachment 134124 [details]
Limit alias name length to Platform maximum field length - Eclipse 1.0.2 patch

Patch against Eclipse 1.0.2 to restrict generated alias names in SQLSelectStatement to the maximum alias length, if specified, and to set the maximum alias length to the maximum field length for the OraclePlatform.

New alias name algorithm truncates the column name as much as needed if the resulting string would be too long.
Comment 7 Peter Krogh CLA 2009-06-25 08:16:30 EDT
Patch checked in as contributed - reviewed by Peter.

Note, at this time the max alias is only get set from the Oracle platform.
Comment 8 Peter Krogh CLA 2009-06-25 08:16:56 EDT
fixing target
Comment 9 Peter Krogh CLA 2009-08-26 09:46:33 EDT
Mass update to change fixed in target.
Comment 10 Peter Krogh CLA 2009-08-26 09:48:53 EDT
Mass update to change fixed in target.
Comment 11 Peter Krogh CLA 2009-08-26 09:53:54 EDT
Mass update to change fixed in target.
Comment 12 Peter Krogh CLA 2009-08-26 09:56:16 EDT
Mass update to change fixed in target.
Comment 13 Peter Krogh CLA 2009-09-22 08:19:53 EDT
This has been backported to 1.1.3.
Comment 15 Gordon Yorke CLA 2009-11-19 10:47:46 EST
*** Bug 294971 has been marked as a duplicate of this bug. ***
Comment 16 David Minsky CLA 2010-04-22 11:29:18 EDT
Base bug was fixed in trunk in r4559
This made its way into 1.2.0
http://fisheye2.atlassian.com/changelog/eclipselink/?cs=4559
Comment 17 Eclipse Webmaster CLA 2022-06-09 10:31:52 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink