Author: max.andersen(a)jboss.com
Date: 2009-05-18 08:45:43 -0400 (Mon, 18 May 2009)
New Revision: 16583
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmToolTest.java
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-3914
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2009-05-18
12:14:54 UTC (rev 16582)
+++
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2009-05-18
12:45:43 UTC (rev 16583)
@@ -390,8 +390,30 @@
public boolean needsTable(PersistentClass clazz) {
- return !(clazz instanceof org.hibernate.mapping.Subclass
- && clazz instanceof org.hibernate.mapping.SingleTableSubclass);
+ Boolean accept = (Boolean) clazz.accept(new PersistentClassVisitor(){
+
+ public Object accept(Subclass subclass) {
+ return Boolean.FALSE;
+ }
+
+ public Object accept(JoinedSubclass subclass) {
+ return Boolean.TRUE;
+ }
+
+ public Object accept(SingleTableSubclass subclass) {
+ return Boolean.FALSE;
+ }
+
+ public Object accept(UnionSubclass subclass) {
+ return Boolean.TRUE;
+ }
+
+ public Object accept(RootClass class1) {
+ return Boolean.TRUE;
+ }
+ });
+
+ return accept.booleanValue();
}
public boolean isSubclass(PersistentClass clazz) {
Modified:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java 2009-05-18
12:14:54 UTC (rev 16582)
+++
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java 2009-05-18
12:45:43 UTC (rev 16583)
@@ -19,6 +19,7 @@
suite.addTest(InheritanceTest.suite());
suite.addTest(SetElementTest.suite());
suite.addTest(BackrefTest.suite());
+ suite.addTest(Cfg2HbmToolTest.suite());
//$JUnit-END$
return suite;
}
Added:
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmToolTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmToolTest.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmToolTest.java 2009-05-18
12:45:43 UTC (rev 16583)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.tool.hbm2x.hbm2hbmxml;
+
+import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.SingleTableSubclass;
+import org.hibernate.mapping.Subclass;
+import org.hibernate.mapping.UnionSubclass;
+import org.hibernate.tool.hbm2x.Cfg2HbmTool;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class Cfg2HbmToolTest extends TestCase {
+
+ public void testNeedsTable(){
+ Cfg2HbmTool c2h = new Cfg2HbmTool();
+ PersistentClass pc = new RootClass();
+ assertTrue(c2h.needsTable(pc));
+ assertTrue(c2h.needsTable(new JoinedSubclass(pc)));
+ assertTrue(c2h.needsTable(new UnionSubclass(pc)));
+ assertFalse(c2h.needsTable(new SingleTableSubclass(pc)));
+ assertFalse(c2h.needsTable(new Subclass(pc)));
+
+ }
+
+ public static Test suite() {
+ return new TestSuite(Cfg2HbmToolTest.class);
+ }
+
+}