Column name not prefixed with table name alias
Description
Activity
Steve EbersoleMarch 21, 2011 at 7:08 PM
Bulk closing stale resolved issues
Jeremy HindmarshMay 19, 2010 at 2:33 AM
Yes I tried putting backticks around the column name. This causes the table name alias to be appended to the column name but puts doubles quotes around the column name as well.
select geoentity0_.EXPIRY_DATE as EXPIRY16_5_0_, geoentity0_."GEOM.SDO_POINT.Y" as GEOM17_5_0_, geoentity0_."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=?
This causes the same invalid identifier exception:
java.sql.SQLException: ORA-00904: "GEOENTITY0_"."GEOM.SDO_POINT.X": invalid identifier
Former userMay 18, 2010 at 8:19 PM
Have you tried putting backticks around the column name, like `GEOM.SDO_POINT.X` ?
Jeremy HindmarshMay 17, 2010 at 3:10 AM
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
);
}
Former userMay 4, 2010 at 12:59 AM
No response and no test case.
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")