HHH-4647 Problems with @JoinColumn referencedColumnName and quoted column and table names
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19433 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
91cbdb8177
commit
9b9d799801
|
@ -6,6 +6,7 @@ import java.io.StringWriter;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,4 +35,32 @@ public class BackquoteTest extends TestCase {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue