From: Stephen F. (JIRA) <no...@at...> - 2006-03-16 15:37:51
|
one-to-many fails on oracle if field starts with underscore ----------------------------------------------------------- Key: HHH-1573 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH= -1573 Project: Hibernate3 Type: Bug Components: core =20 Versions: 3.1.2 =20 Reporter: Stephen Friedrich Hibernate generates SQL that is invalid on Oracle, because it has fields in= the select clause that start with an underscore. This is my field declaration: @OneToMany(cascade =3D CascadeType.ALL, fetch =3D FetchType.EAGER, mapp= edBy =3D "_user") private Set<Permission> _permissions =3D new HashSet<Permission>(); And this is the generated SQL: select =09_permissio0_.user_id as user4_2_, =09_permissio0_.id as id2_,=20 =09_permissio0_.id as id40_1_,=20 =09_permissio0_.version as version40_1_,=20 =09_permissio0_.guid as guid40_1_,=20 =09_permissio0_.user_id as user4_40_1_,=20 =09_permissio0_2_.company_reference_id as company2_42_1_,=20 case =09when _permissio0_1_.permission_id is not null then 1=20 =09when _permissio0_2_.permission_id is not null then 2=20 =09when _permissio0_.id is not null then 0 end as =09clazz_1_, =09companyref1_.id as id43_0_, =09companyref1_.version as version43_0_, =09companyref1_.guid as guid43_0_, =09companyref1_.db_user_name as db4_43_0_,=20 =09companyref1_.company_name as company5_43_0_=20 from=20 =09permissions _permissio0_=20 =09left outer join admin_permissions _permissio0_1_ on _permissio0_.id=3D_p= ermissio0_1_.permission_id=20 =09left outer join company_permissions _permissio0_2_ on _permissio0_.id=3D= _permissio0_2_.permission_id=20 =09left outer join company_references companyref1_ on _permissio0_2_.compan= y_reference_id=3Dcompanyref1_.id=20 where _permissio0_.user_id=3D? When executed Oracle gives this error: "ORA-00911: Ung=C2=B3ltiges Zeichen"= ("invalid character" in german) If I remove the underscore in front of every occurence of "_permissio..." t= hen I can execute the SQL fine on the command line ("?" replaced by 1). This has been reported on the forum, but nobody answered. See last post in= =20 http://forums.hibernate.org/viewtopic.php?t=3D929011&highlight=3Dora00911&s= id=3Dc501920d028c78899884f5bfac8e827e --=20 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 |
From: Anonymous (JIRA) <no...@at...> - 2006-06-23 09:54:33
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1573?p= age=3Dall ] updated HHH-1573: ------------------ Attachment: leadingunderscore.zip org.hibernate.util.StringHelper.patch > one-to-many fails on oracle if field starts with underscore > ----------------------------------------------------------- > > Key: HHH-1573 > URL: http://opensource.atlassian.com/projects/hibernate/browse/H= HH-1573 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.1.2 > Reporter: Stephen Friedrich > Attachments: leadingunderscore.zip, org.hibernate.util.StringHelper.patc= h > > > Hibernate generates SQL that is invalid on Oracle, because it has fields = in the select clause that start with an underscore. > This is my field declaration: > @OneToMany(cascade =3D CascadeType.ALL, fetch =3D FetchType.EAGER, ma= ppedBy =3D "_user") > private Set<Permission> _permissions =3D new HashSet<Permission>(); > And this is the generated SQL: > select > =09_permissio0_.user_id as user4_2_, > =09_permissio0_.id as id2_,=20 > =09_permissio0_.id as id40_1_,=20 > =09_permissio0_.version as version40_1_,=20 > =09_permissio0_.guid as guid40_1_,=20 > =09_permissio0_.user_id as user4_40_1_,=20 > =09_permissio0_2_.company_reference_id as company2_42_1_,=20 > case > =09when _permissio0_1_.permission_id is not null then 1=20 > =09when _permissio0_2_.permission_id is not null then 2=20 > =09when _permissio0_.id is not null then 0 > end > as > =09clazz_1_, > =09companyref1_.id as id43_0_, > =09companyref1_.version as version43_0_, > =09companyref1_.guid as guid43_0_, > =09companyref1_.db_user_name as db4_43_0_,=20 > =09companyref1_.company_name as company5_43_0_=20 > from=20 > =09permissions _permissio0_=20 > =09left outer join admin_permissions _permissio0_1_ on _permissio0_.id=3D= _permissio0_1_.permission_id=20 > =09left outer join company_permissions _permissio0_2_ on _permissio0_.id= =3D_permissio0_2_.permission_id=20 > =09left outer join company_references companyref1_ on _permissio0_2_.comp= any_reference_id=3Dcompanyref1_.id=20 > where _permissio0_.user_id=3D? > When executed Oracle gives this error: "ORA-00911: Ung=C2=B3ltiges Zeiche= n" ("invalid character" in german) > If I remove the underscore in front of every occurence of "_permissio..."= then I can execute the SQL fine on the command line ("?" replaced by 1). > This has been reported on the forum, but nobody answered. See last post i= n=20 > http://forums.hibernate.org/viewtopic.php?t=3D929011&highlight=3Dora00911= &sid=3Dc501920d028c78899884f5bfac8e827e --=20 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 |
From: Marco R. (JIRA) <no...@at...> - 2006-06-23 10:02:31
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1573?pa= ge=3Dcomments#action_23380 ]=20 Marco Reimann commented on HHH-1573: ------------------------------------ Since I also encountered this problem I created a TestCase to reproduce it = based on the 3.2 CR2 Release and a fix that in my opinion solves the proble= m.=20 To run the test, unpack leadingunderscore.zip into the Hibernate3/test/org/= hibernate/test directory. Could you please check this out and include the fix in one of the next rele= ases? Thanks Marco Reimann > one-to-many fails on oracle if field starts with underscore > ----------------------------------------------------------- > > Key: HHH-1573 > URL: http://opensource.atlassian.com/projects/hibernate/browse/H= HH-1573 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.1.2 > Reporter: Stephen Friedrich > Attachments: leadingunderscore.zip, org.hibernate.util.StringHelper.patc= h > > > Hibernate generates SQL that is invalid on Oracle, because it has fields = in the select clause that start with an underscore. > This is my field declaration: > @OneToMany(cascade =3D CascadeType.ALL, fetch =3D FetchType.EAGER, ma= ppedBy =3D "_user") > private Set<Permission> _permissions =3D new HashSet<Permission>(); > And this is the generated SQL: > select > =09_permissio0_.user_id as user4_2_, > =09_permissio0_.id as id2_,=20 > =09_permissio0_.id as id40_1_,=20 > =09_permissio0_.version as version40_1_,=20 > =09_permissio0_.guid as guid40_1_,=20 > =09_permissio0_.user_id as user4_40_1_,=20 > =09_permissio0_2_.company_reference_id as company2_42_1_,=20 > case > =09when _permissio0_1_.permission_id is not null then 1=20 > =09when _permissio0_2_.permission_id is not null then 2=20 > =09when _permissio0_.id is not null then 0 > end > as > =09clazz_1_, > =09companyref1_.id as id43_0_, > =09companyref1_.version as version43_0_, > =09companyref1_.guid as guid43_0_, > =09companyref1_.db_user_name as db4_43_0_,=20 > =09companyref1_.company_name as company5_43_0_=20 > from=20 > =09permissions _permissio0_=20 > =09left outer join admin_permissions _permissio0_1_ on _permissio0_.id=3D= _permissio0_1_.permission_id=20 > =09left outer join company_permissions _permissio0_2_ on _permissio0_.id= =3D_permissio0_2_.permission_id=20 > =09left outer join company_references companyref1_ on _permissio0_2_.comp= any_reference_id=3Dcompanyref1_.id=20 > where _permissio0_.user_id=3D? > When executed Oracle gives this error: "ORA-00911: Ung=C2=B3ltiges Zeiche= n" ("invalid character" in german) > If I remove the underscore in front of every occurence of "_permissio..."= then I can execute the SQL fine on the command line ("?" replaced by 1). > This has been reported on the forum, but nobody answered. See last post i= n=20 > http://forums.hibernate.org/viewtopic.php?t=3D929011&highlight=3Dora00911= &sid=3Dc501920d028c78899884f5bfac8e827e --=20 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 |