From noreply at atlassian.com Tue Dec 8 09:20:10 2009 Content-Type: multipart/mixed; boundary="===============2735374541801695257==" MIME-Version: 1.0 From: Emmanuel Bernard (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4553) Hibernate doesn't support official JPA2 escape char for table name Date: Tue, 08 Dec 2009 08:20:09 -0600 Message-ID: <1039717850.3457.1260282009971.JavaMail.j2ee-opensource-projects@vps07.contegix.com> In-Reply-To: 189353470.433.1257765253070.JavaMail.j2ee-opensource-projects@vps07.contegix.com --===============2735374541801695257== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4553?pa= ge=3Dcom.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focus= edCommentId=3D34883#action_34883 ] = Emmanuel Bernard commented on HHH-4553: --------------------------------------- Make sure that "When using XML, a name is specified as a delimited identifier by use of do= uble = quotes, e.g., " properly works > Hibernate doesn't support official JPA2 escape char for table name > ------------------------------------------------------------------ > > Key: HHH-4553 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/HHH-4553 > Project: Hibernate Core > Issue Type: Sub-task > Affects Versions: 3.5.0-Beta-2 > Environment: Oracle 9i > Derby > Reporter: Julien HENRY > Assignee: Steve Ebersole > Fix For: 3.5 > > Time Spent: 6 hours, 35 minutes > Remaining Estimate: 0 minutes > > One of the table of my schema is named FUNCTION. As it is a reserved name= with Derby (used for my JUnit tests), I have escaped the table name to mak= e it works with Derby (as specified by JPA2 spec $2.13): > @Entity > @Table(name=3D"\"FUNCTION\"") > public class Function { > //... > } > My JUnit tests are working fine, then I tried to connect to my Oracle DB,= and I have enabled schema validation: > > But I got an exception as Hibernate is looking for a table with name "FUN= CTION" in Oracle metadata. > Caused by: org.hibernate.HibernateException: Missing table: "FUNCTION" > at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:115= 3) [hibernate-core-3.5.0-Beta-2.jar:3.5.0-Beta-2] > at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.j= ava:139) [hibernate-core-3.5.0-Beta-2.jar:3.5.0-Beta-2] > at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:= 364) [hibernate-core-3.5.0-Beta-2.jar:3.5.0-Beta-2] > at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav= a:1367) [hibernate-core-3.5.0-Beta-2.jar:3.5.0-Beta-2] > at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat= ionConfiguration.java:858) [hibernate-annotations-3.5.0-Beta-2.jar:3.5.0-Be= ta-2] > at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con= figuration.java:733) [hibernate-entitymanager-3.5.0-Beta-2.jar:3.5.0-Beta-2] > This is not specific to Oracle, because when I change: > > by > > in my JUnit tests, I have the same issue with the embedded Derby DB. > Using Hibernate specific ` as quote works fine: > @Entity > @Table(name=3D"`FUNCTION`") > public class Function { > //... > } > The issue can be easily fixed in Table.setName(String name). Replace: > if ( name.charAt( 0 ) =3D=3D '`' ) { > by > if ( name.charAt( 0 ) =3D=3D '"' ) { > or if you want to keep backward compatibility: > if ( name.charAt( 0 ) =3D=3D '`' || name.charAt( 0 ) =3D=3D '"' ) { -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============2735374541801695257==--