Index: src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java =================================================================== --- src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java (revision 23368) +++ src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaManyToManyMapping.java (working copy) @@ -16,6 +16,7 @@ import java.util.Vector; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.JpaFactory; import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.core.context.java.JavaRelationshipReference; import org.eclipse.jpt.core.internal.context.java.AbstractJavaManyToManyMapping; @@ -29,6 +30,7 @@ import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage; import org.jboss.tools.hibernate.jpt.core.internal.context.Messages; import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate; +import org.jboss.tools.hibernate.jpt.core.internal.jpa2.HibernateJpaFactory2_0; /** * @author Dmitry Geraskov @@ -56,8 +58,8 @@ } @Override - protected HibernateJpaFactory getJpaFactory() { - return (HibernateJpaFactory) super.getJpaFactory(); + protected JpaFactory getJpaFactory() { + return super.getJpaFactory(); } @Override @@ -104,13 +106,21 @@ if (getForeignKey() != null) { throw new IllegalStateException("foreignKey already exists"); //$NON-NLS-1$ } - this.foreignKey = getJpaFactory().buildForeignKey(this); + this.foreignKey = buildForeignKey(); ForeignKeyAnnotation foreignKeyResource = (ForeignKeyAnnotation) getResourcePersistentAttribute().addAnnotation(ForeignKeyAnnotation.ANNOTATION_NAME); this.foreignKey.initialize(foreignKeyResource); firePropertyChanged(FOREIGN_KEY_PROPERTY, null, this.foreignKey); return this.foreignKey; } + private ForeignKey buildForeignKey() { + if (getJpaFactory() instanceof HibernateJpaFactory) + return ((HibernateJpaFactory) getJpaFactory()).buildForeignKey(this); + if (getJpaFactory() instanceof HibernateJpaFactory2_0) + return ((HibernateJpaFactory2_0) getJpaFactory()).buildForeignKey(this); + return null; + } + public ForeignKey getForeignKey() { return this.foreignKey; } @@ -132,7 +142,7 @@ } protected ForeignKey buildForeignKey(ForeignKeyAnnotation foreignKeyResource) { - ForeignKey foreignKey = getJpaFactory().buildForeignKey(this); + ForeignKey foreignKey = buildForeignKey(); foreignKey.initialize(foreignKeyResource); return foreignKey; } Index: src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java =================================================================== --- src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java (revision 23368) +++ src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpaFactory2_0.java (working copy) @@ -16,6 +16,7 @@ import org.eclipse.jpt.core.context.java.JavaAssociationOverride; import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer; import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference; +import org.eclipse.jpt.core.context.java.JavaColumn; import org.eclipse.jpt.core.context.java.JavaEmbeddable; import org.eclipse.jpt.core.context.java.JavaJpaContextNode; import org.eclipse.jpt.core.context.java.JavaManyToOneMapping; @@ -26,7 +27,9 @@ import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.java.JavaSequenceGenerator; +import org.eclipse.jpt.core.context.java.JavaBaseColumn.Owner; import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaAssociationOverrideContainer; +import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaColumn; import org.eclipse.jpt.core.internal.jpa2.GenericMetamodelSynchronizer; import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaAssociationOverrideRelationshipReference2_0; import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaCacheable2_0; @@ -173,5 +176,9 @@ public JavaOrderColumn2_0 buildJavaOrderColumn(JavaOrderable2_0 parent, JavaNamedColumn.Owner owner) { return new GenericJavaOrderColumn2_0(parent, owner); } - + + @Override + public JavaColumn buildJavaMapKeyColumn(JavaJpaContextNode parent, Owner owner) { + return new GenericJavaColumn(parent, owner); + } }