Author: sharathjreddy
Date: 2010-07-01 07:26:39 -0400 (Thu, 01 Jul 2010)
New Revision: 19883
Added:
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/Printer.java
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/PrinterCable.java
Modified:
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/BackquoteTest.java
Log:
HHH-4647 Problems with @JoinColumn referencedColumnName and quoted column and table names
Modified:
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/BackquoteTest.java
===================================================================
---
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/BackquoteTest.java 2010-07-01
11:25:53 UTC (rev 19882)
+++
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/BackquoteTest.java 2010-07-01
11:26:39 UTC (rev 19883)
@@ -6,6 +6,7 @@
import junit.framework.TestCase;
+import org.hibernate.MappingException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,4 +35,33 @@
fail(e.getMessage());
}
}
+
+ /**
+ * HHH-4647 : Problems with @JoinColumn referencedColumnName and quoted column and
table names
+ *
+ * An invalid referencedColumnName to an entity having a quoted table name results in
an
+ * infinite loop in o.h.c.Configuration$MappingsImpl#getPhysicalColumnName().
+ * The same issue exists with getLogicalColumnName()
+ */
+ public void testInvalidReferenceToQuotedTableName() {
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.addAnnotatedClass(Printer.class);
+ config.addAnnotatedClass(PrinterCable.class);
+ config.buildSessionFactory();
+ fail("expected MappingException to be thrown");
+ }
+ //we WANT MappingException to be thrown
+ catch( MappingException e ) {
+ assertTrue("MappingException was thrown", true);
+ }
+ catch(Exception e) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
+ fail(e.getMessage());
+ }
+ }
+
+
}
Added:
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/Printer.java
===================================================================
---
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/Printer.java
(rev 0)
+++
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/Printer.java 2010-07-01
11:26:39 UTC (rev 19883)
@@ -0,0 +1,48 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-
+ * party contributors as indicated by the @author tags or express
+ * copyright attribution statements applied by the authors.
+ * All third-party contributions are distributed under license by
+ * Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to
+ * use, modify, copy, or redistribute it subject to the terms and
+ * conditions of the GNU Lesser General Public License, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this distribution; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.annotations.backquotes;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Entity
+@Table(name="`Printer`")
+public class Printer {
+ private Long id;
+
+ @Id
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
\ No newline at end of file
Added:
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/PrinterCable.java
===================================================================
---
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/PrinterCable.java
(rev 0)
+++
core/branches/Branch_3_5/annotations/src/test/java/org/hibernate/test/annotations/backquotes/PrinterCable.java 2010-07-01
11:26:39 UTC (rev 19883)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-
+ * party contributors as indicated by the @author tags or express
+ * copyright attribution statements applied by the authors.
+ * All third-party contributions are distributed under license by
+ * Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to
+ * use, modify, copy, or redistribute it subject to the terms and
+ * conditions of the GNU Lesser General Public License, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this distribution; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.annotations.backquotes;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class PrinterCable {
+ private Long id;
+ private Printer printer;
+
+ @Id
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @ManyToOne
+ @JoinColumn(name="aId", referencedColumnName="missing")
+ public Printer getPrinter() {
+ return printer;
+ }
+
+ public void setPrinter(Printer a) {
+ this.printer = a;
+ }
+}
\ No newline at end of file
Show replies by date