Author: mdryakhlenkov
Date: 2007-08-13 10:29:07 -0400 (Mon, 13 Aug 2007)
New Revision: 3091
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java
Log:
JBIDE-700: Hibernate diagram fails on simplest mapping
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-08-13
14:25:04 UTC (rev 3090)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-08-13
14:29:07 UTC (rev 3091)
@@ -141,7 +141,7 @@
if (ormElement instanceof RootClass) {
ormShape = new OrmShape(ormElement);
getChildren().add(ormShape);
- elements.put(((RootClass)ormElement).getEntityName(), ormShape);
+ elements.put(HibernateUtils.getPersistentClassName(((RootClass)ormElement).getEntityName()),
ormShape);
} else if (ormElement instanceof Table) {
ormShape = new OrmShape(ormElement);
getChildren().add(ormShape);
@@ -150,11 +150,11 @@
SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
ormShape = new SpecialOrmShape(specialRootClass);
getChildren().add(ormShape);
- elements.put(specialRootClass.getEntityName(), ormShape);
+ elements.put(HibernateUtils.getPersistentClassName(specialRootClass.getEntityName()),
ormShape);
} else if (ormElement instanceof Subclass) {
ormShape = new OrmShape(ormElement);
getChildren().add(ormShape);
- elements.put(((Subclass)ormElement).getEntityName(), ormShape);
+ elements.put(HibernateUtils.getPersistentClassName(((Subclass)ormElement).getEntityName()),
ormShape);
}
return ormShape;
}
@@ -162,14 +162,14 @@
public OrmShape getShape(Object ormElement) {
OrmShape ormShape = null;
if (ormElement instanceof RootClass) {
- ormShape = elements.get(((RootClass)ormElement).getEntityName());
+ ormShape =
elements.get(HibernateUtils.getPersistentClassName(((RootClass)ormElement).getEntityName()));
} else if (ormElement instanceof Table) {
ormShape = elements.get(HibernateUtils.getTableName((Table)ormElement));
} else if (ormElement instanceof Property) {
SpecialRootClass specialRootClass = new SpecialRootClass((Property)ormElement);
- ormShape = elements.get(specialRootClass.getEntityName());
+ ormShape =
elements.get(HibernateUtils.getPersistentClassName(specialRootClass.getEntityName()));
} else if (ormElement instanceof Subclass) {
- ormShape = elements.get(((Subclass)ormElement).getEntityName());
+ ormShape =
elements.get(HibernateUtils.getPersistentClassName(((Subclass)ormElement).getEntityName()));
}
return ormShape;
}
@@ -179,7 +179,7 @@
OrmShape classShape = null;
OrmShape shape = null;
if(persistentClass != null) {
- classShape = elements.get(persistentClass.getEntityName());
+ classShape =
elements.get(HibernateUtils.getPersistentClassName(persistentClass.getEntityName()));
if (classShape == null) classShape = createShape(persistentClass);
if(componentClassDatabaseTable == null && persistentClass.getTable() != null)
componentClassDatabaseTable = persistentClass.getTable();
@@ -199,7 +199,7 @@
Object element = iter.next();
if (element instanceof Subclass) {
Subclass subclass = (Subclass)element;
- OrmShape subclassShape = elements.get(subclass.getEntityName());
+ OrmShape subclassShape =
elements.get(HibernateUtils.getPersistentClassName(subclass.getEntityName()));
if (subclassShape == null) subclassShape = createShape(subclass);
if (((Subclass)element).isJoinedSubclass()) {
Table jcTable = ((Subclass)element).getTable();
@@ -290,7 +290,7 @@
RootClass cls = (RootClass)clazz;
Table table = cls.getTable();
if (tableName.equals(table.getName() + "." + table.getName())) {
- if (elements.get(cls.getEntityName()) == null)
+ if (elements.get(HibernateUtils.getPersistentClassName(cls.getEntityName())) ==
null)
getOrCreatePersistentClass(cls, null);
}
}
@@ -506,7 +506,7 @@
}
Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
if (parentShape != null) {
- OrmShape parentClassShape =
(OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getEntityName());
+ OrmShape parentClassShape =
(OrmShape)elements.get(HibernateUtils.getPersistentClassName(((Property)parentShape.getOrmElement()).getPersistentClass().getEntityName()));
if(!isConnectionExist(parentShape, parentClassShape)){
new Connection(parentShape, parentClassShape);
parentShape.firePropertyChange(REFRESH, null, null);
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java 2007-08-13
14:25:04 UTC (rev 3090)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.view/src/org/jboss/tools/hibernate/ui/view/views/HibernateUtils.java 2007-08-13
14:29:07 UTC (rev 3091)
@@ -4,6 +4,8 @@
import org.hibernate.mapping.Column;
import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.RootClass;
import org.hibernate.mapping.Table;
public class HibernateUtils {
@@ -13,6 +15,13 @@
String schema = table.getSchema();
return (catalog != null ? catalog + "." : "") + (schema != null ?
schema + "." : "") + table.getName();
}
+
+ public static String getPersistentClassName(String className) {
+ if (className.indexOf(".") < 0) {
+ return "default." + className;
+ }
+ return className;
+ }
public static boolean isPrimaryKey(Column column){
Table table = getTable(column);
Show replies by date