[hibernate-commits] Hibernate SVN: r14741 - in annotations/trunk/src: java/org/hibernate/cfg/annotations and 2 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Jun 5 07:25:56 EDT 2008


Author: hardy.ferentschik
Date: 2008-06-05 07:25:56 -0400 (Thu, 05 Jun 2008)
New Revision: 14741

Added:
   annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/
   annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java
   annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java
   annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
   annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java
Modified:
   annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java
   annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java
Log:
ANN-716:
- Added test harness
- In EntityBinder made sure that the realTable instead of table is used in the joins map

Modified: annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java	2008-06-05 09:10:41 UTC (rev 14740)
+++ annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java	2008-06-05 11:25:56 UTC (rev 14741)
@@ -7,7 +7,7 @@
 import org.hibernate.util.StringHelper;
 
 /**
- * NAming strategy implementing the EJB3 standards
+ * Naming strategy implementing the EJB3 standards
  *
  * @author Emmanuel Bernard
  */

Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java	2008-06-05 09:10:41 UTC (rev 14740)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java	2008-06-05 11:25:56 UTC (rev 14741)
@@ -667,8 +667,8 @@
 			createPrimaryColumnsToSecondaryTable( joinColumns, propertyHolder, join );
 		}
 		else {
-			secondaryTables.put( table, join );
-			secondaryTableJoins.put( table, joinColumns );
+			secondaryTables.put( realTable, join );
+			secondaryTableJoins.put( realTable, joinColumns );
 		}
 		return join;
 	}

Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java	                        (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java	2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,34 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToOne;
+
+ at Entity
+public class Address {
+
+	@Id
+	private long id;
+
+	@ManyToOne
+	@JoinTable(name = "person_address")
+	private Person person;
+
+	public long getId() {
+		return id;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public Person getPerson() {
+		return person;
+	}
+
+	public void setPerson(Person person) {
+		this.person = person;
+	}
+}


Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java	                        (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java	2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,13 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import org.hibernate.cfg.EJB3NamingStrategy;
+
+ at SuppressWarnings("serial")
+public class DummyNamingStrategy extends EJB3NamingStrategy {
+	
+	public String tableName(String tableName) {
+		return "T" + tableName;
+	}
+
+}


Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java	                        (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java	2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,52 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test harness for ANN-716.
+ * 
+ * @author Hardy Ferentschik
+ */
+public class NamingStrategyTest extends TestCase {
+	
+	private Logger log = LoggerFactory.getLogger(NamingStrategyTest.class);
+
+	public void testWithCustomNamingStrategy() throws Exception {
+		try {
+			AnnotationConfiguration config = new AnnotationConfiguration();
+			config.setNamingStrategy(new DummyNamingStrategy());
+			config.addAnnotatedClass(Address.class);
+			config.addAnnotatedClass(Person.class);
+			config.buildSessionFactory();
+		}
+		catch( Exception e ) {
+			StringWriter writer = new StringWriter();
+			e.printStackTrace(new PrintWriter(writer));
+			log.debug(writer.toString());
+			fail(e.getMessage());
+		}
+	}
+	
+	public void testWithoutCustomNamingStrategy() throws Exception {
+		try {
+			AnnotationConfiguration config = new AnnotationConfiguration();
+			config.addAnnotatedClass(Address.class);
+			config.addAnnotatedClass(Person.class);
+			config.buildSessionFactory();
+		}
+		catch( Exception e ) {
+			StringWriter writer = new StringWriter();
+			e.printStackTrace(new PrintWriter(writer));
+			log.debug(writer.toString());
+			fail(e.getMessage());
+		}
+	}	
+}


Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java	                        (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java	2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,35 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+ at Entity
+public class Person {
+
+	@Id
+	private long id;
+
+	@OneToMany(mappedBy = "person")
+	private Set<Address> addresses = new HashSet<Address>();
+
+	public long getId() {
+		return id;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public Set<Address> getAddresses() {
+		return addresses;
+	}
+
+	public void setAddresses(Set<Address> addresses) {
+		this.addresses = addresses;
+	}
+}


Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native




More information about the hibernate-commits mailing list