Author: epbernard
Date: 2010-01-27 12:22:13 -0500 (Wed, 27 Jan 2010)
New Revision: 18653
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/Phone.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteGlobalTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/Phone.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/QuotingTest.java
core/trunk/entitymanager/src/test/resources/org/hibernate/ejb/test/mapping/
core/trunk/entitymanager/src/test/resources/org/hibernate/ejb/test/mapping/orm.xml
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteTest.java
Log:
HHH-4855 globally quoting identifiers was incorrectly considered an actual table name
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java 2010-01-27
16:58:46 UTC (rev 18652)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/Ejb3Column.java 2010-01-27
17:22:13 UTC (rev 18653)
@@ -352,7 +352,12 @@
}
public void setSecondaryTableName(String secondaryTableName) {
- this.secondaryTableName = secondaryTableName;
+ if ( "``".equals( secondaryTableName ) ) {
+ this.secondaryTableName = "";
+ }
+ else {
+ this.secondaryTableName = secondaryTableName;
+ }
}
public static Ejb3Column[] buildColumnFromAnnotation(
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/Phone.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/Phone.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/Phone.java 2010-01-27
17:22:13 UTC (rev 18653)
@@ -0,0 +1,52 @@
+package org.hibernate.test.annotations.quote;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityResult;
+import javax.persistence.Id;
+import javax.persistence.NamedNativeQueries;
+import javax.persistence.NamedNativeQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "PHONE")
+public class Phone implements java.io.Serializable {
+
+ private Integer id;
+ private String brandName;
+ private float price;
+
+ public Phone() {
+ }
+
+ @Id
+ @Column(name="ID")
+ public Integer getId() {
+ return id;
+ }
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Column(name="BRANDNAME")
+ public String getBrandName() {
+ return brandName;
+ }
+ public void setBrandName(String bName) {
+ this.brandName = bName;
+ }
+
+ @Column(name="PRICE")
+ public float getPrice() {
+ return price;
+ }
+ public void setPrice(float price) {
+ this.price = price;
+ }
+}
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteGlobalTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteGlobalTest.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteGlobalTest.java 2010-01-27
17:22:13 UTC (rev 18653)
@@ -0,0 +1,45 @@
+package org.hibernate.test.annotations.quote;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class QuoteGlobalTest extends TestCase {
+ public void testQuoteManytoMany() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ User u = new User();
+ s.persist( u );
+ Role r = new Role();
+ s.persist( r );
+ u.getRoles().add( r );
+ s.flush();
+ s.clear();
+ u = (User) s.get( User.class, u.getId() );
+ assertEquals( 1, u.getRoles().size() );
+ tx.rollback();
+ String role = User.class.getName() + ".roles";
+ assertEquals( "User_Role", getCfg().getCollectionMapping( role
).getCollectionTable().getName() );
+ s.close();
+ }
+
+
+ @Override
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( Environment.GLOBALLY_QUOTED_IDENTIFIERS, "true" );
+ }
+
+ protected Class[] getAnnotatedClasses() {
+ return new Class[] {
+ User.class,
+ Role.class,
+ Phone.class
+ };
+ }
+}
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteTest.java 2010-01-27
16:58:46 UTC (rev 18652)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/quote/QuoteTest.java 2010-01-27
17:22:13 UTC (rev 18653)
@@ -29,7 +29,8 @@
protected Class[] getAnnotatedClasses() {
return new Class[] {
User.class,
- Role.class
+ Role.class,
+ Phone.class
};
}
}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/Phone.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/Phone.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/Phone.java 2010-01-27
17:22:13 UTC (rev 18653)
@@ -0,0 +1,52 @@
+package org.hibernate.ejb.test.mapping;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EntityResult;
+import javax.persistence.Id;
+import javax.persistence.NamedNativeQueries;
+import javax.persistence.NamedNativeQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.SqlResultSetMapping;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "PHONE")
+public class Phone implements java.io.Serializable {
+
+ private Integer id;
+ private String brandName;
+ private float price;
+
+ public Phone() {
+ }
+
+ @Id
+ @Column(name="ID")
+ public Integer getId() {
+ return id;
+ }
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Column(name="BRANDNAME")
+ public String getBrandName() {
+ return brandName;
+ }
+ public void setBrandName(String bName) {
+ this.brandName = bName;
+ }
+
+ @Column(name="PRICE")
+ public float getPrice() {
+ return price;
+ }
+ public void setPrice(float price) {
+ this.price = price;
+ }
+}
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/QuotingTest.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/QuotingTest.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/mapping/QuotingTest.java 2010-01-27
17:22:13 UTC (rev 18653)
@@ -0,0 +1,27 @@
+package org.hibernate.ejb.test.mapping;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class QuotingTest extends TestCase {
+
+ public void testQuote() {
+ // the configuration was failing
+ }
+
+ @Override
+ public String[] getEjb3DD() {
+ return new String[] {
+ "org/hibernate/ejb/test/mapping/orm.xml"
+ };
+ }
+
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] {
+ Phone.class
+ };
+ }
+}
Added: core/trunk/entitymanager/src/test/resources/org/hibernate/ejb/test/mapping/orm.xml
===================================================================
--- core/trunk/entitymanager/src/test/resources/org/hibernate/ejb/test/mapping/orm.xml
(rev 0)
+++
core/trunk/entitymanager/src/test/resources/org/hibernate/ejb/test/mapping/orm.xml 2010-01-27
17:22:13 UTC (rev 18653)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
version="2.0">
+ <persistence-unit-metadata>
+ <persistence-unit-defaults>
+ <delimited-identifiers/>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+</entity-mappings>