[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5005) Column name not prefixed with table name alias

Jeremy Hindmarsh (JIRA) noreply at atlassian.com
Sun May 16 21:12:24 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37160#action_37160 ] 

Jeremy Hindmarsh commented on HHH-5005:
---------------------------------------

A full stop is a dot ("."). Maybe you call it a period. If it is used as part of a column name eg "GEOM.SDO_POINT.X" then I get the following exception java.sql.SQLException: ORA-00904: "GEOM"."SDO_POINT"."X": invalid identifier.  

This is because the generated query doesn't append the table alias to the column name.

select geoentity0_.EXPIRY_DATE as EXPIRY16_5_0_, GEOM.SDO_POINT.Y as GEOM17_5_0_, GEOM.SDO_POINT.X as GEOM18_5_0_, geoentity0_.PARENT as PARENT5_0_, geoentity0_.QABY as QABY5_0_, geoentity0_.QADATE as QADATE5_0 from ENTITIES geoentity0_ where geoentity0_.ENO=?


I have just tried hibernate 3.5.1-Final and still get this exception.  I guess I'll continue to use the work around previously mentioned.


This method in Template.java ignores any column name that contains a period and therefore doesn't add the table name alias.

private static boolean isIdentifier(String token, Dialect dialect) {
		return token.charAt(0)=='`' || ( //allow any identifier quoted with backtick
			Character.isLetter( token.charAt(0) ) && //only recognizes identifiers beginning with a letter
			token.indexOf('.') < 0
		);
	}



> Column name not prefixed with table name alias
> ----------------------------------------------
>
>                 Key: HHH-5005
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5005
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: annotations
>    Affects Versions: 3.5.0-CR-2
>         Environment: Hibernate 3.5 CR2, Oracle 10g
>            Reporter: Jeremy Hindmarsh
>            Assignee: Gail Badner
>
> If a column name annotation contains a full stop, the column name is not prefixed with the table name alias.
> Some of our database tables contain Oracle spatial data. One in particular has two columns for longitude and latitude,
> GEOM.SDO_POINT.X and GEOM.SDO_POINT.Y
> The problem is that the table alias is not added to the column name due to isIdentifier method in the Template class.
> This method returns false because the column name contains full stops.
> This means the renderWhereStringTemplate method doesn't prefix the column name with the table alias placeholder.
> Fortunately for now I can use the following column definition, in order to get the table alias added.
> @Column(name = "$PlaceHolder$.GEOM.SDO_POINT.X")

-- 
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