use of org.eclipse.jpt.jpa.core.context.java.JavaPersistentType in project jbosstools-hibernate by jbosstools.
the class HibernateJpaModelTests method checkManyToManyNS2.
public void checkManyToManyNS2(ClassRef crs) {
JavaPersistentType javaPersistentType = crs.getJavaPersistentType();
JavaTypeMapping mapping = javaPersistentType.getMapping();
assertTrue(mapping instanceof HibernateJavaEntity);
HibernateJavaEntity entity = (HibernateJavaEntity) mapping;
HibernateJavaTable table = entity.getTable();
assertEquals("tn_ManyToMany22", table.getDBTableName());
ArrayList<JavaSpecifiedPersistentAttribute> attrs = IterableTools.list(javaPersistentType.getAttributes());
assertTrue(attrs.size() == 3);
// id
assertTrue(attrs.get(0).getMapping() instanceof HibernateJavaIdMapping);
HibernateJavaIdMapping hjidm = (HibernateJavaIdMapping) attrs.get(0).getMapping();
HibernateJavaColumn hjc = (HibernateJavaColumn) hjidm.getColumn();
assertEquals("cn_id", hjc.getDBColumnName());
// justData
assertTrue(attrs.get(1).getMapping() instanceof HibernateJavaBasicMapping);
HibernateJavaBasicMapping hjbm = (HibernateJavaBasicMapping) attrs.get(1).getMapping();
hjc = (HibernateJavaColumn) hjbm.getColumn();
assertEquals("cn_justData", hjc.getDBColumnName());
// mtm
assertTrue(attrs.get(2).getMapping() instanceof HibernateJavaManyToManyMapping);
HibernateJavaManyToManyMapping hjmtmm = (HibernateJavaManyToManyMapping) attrs.get(2).getMapping();
assertEquals("entity.ManyToMany1", hjmtmm.getTargetEntity());
JavaSpecifiedJoinTableRelationshipStrategy jtJoiningStrategy = hjmtmm.getRelationship().getJoinTableStrategy();
JavaSpecifiedJoinTable joinTable = jtJoiningStrategy.getJoinTable();
assertTrue(joinTable instanceof HibernateJavaJoinTable);
HibernateJavaJoinTable hjjt = (HibernateJavaJoinTable) joinTable;
hjjt.getDbTable();
assertEquals("col_entity.ManyToMany2_entity.ManyToMany1_ManyToMany1_entity.ManyToMany1_mtm1", hjjt.getDBTableName());
}
use of org.eclipse.jpt.jpa.core.context.java.JavaPersistentType in project jbosstools-hibernate by jbosstools.
the class HibernateJpaModelTests method checkManyToManyNS1.
public void checkManyToManyNS1(ClassRef crs) {
JavaPersistentType javaPersistentType = crs.getJavaPersistentType();
JavaTypeMapping mapping = javaPersistentType.getMapping();
assertTrue(mapping instanceof HibernateJavaEntity);
HibernateJavaEntity entity = (HibernateJavaEntity) mapping;
HibernateJavaTable table = entity.getTable();
assertEquals("ctn_ManyToMany1", table.getDBTableName());
ArrayList<JavaSpecifiedPersistentAttribute> attrs = IterableTools.list(javaPersistentType.getAttributes());
assertTrue(attrs.size() == 3);
// id
assertTrue(attrs.get(0).getMapping() instanceof HibernateJavaIdMapping);
HibernateJavaIdMapping hjidm = (HibernateJavaIdMapping) attrs.get(0).getMapping();
HibernateJavaColumn hjc = (HibernateJavaColumn) hjidm.getColumn();
assertEquals("pc_id1", hjc.getDBColumnName());
// justData
assertTrue(attrs.get(1).getMapping() instanceof HibernateJavaBasicMapping);
HibernateJavaBasicMapping hjbm = (HibernateJavaBasicMapping) attrs.get(1).getMapping();
hjc = (HibernateJavaColumn) hjbm.getColumn();
assertEquals("pc_justData1", hjc.getDBColumnName());
// mtm
assertTrue(attrs.get(2).getMapping() instanceof HibernateJavaManyToManyMapping);
HibernateJavaManyToManyMapping hjmtmm = (HibernateJavaManyToManyMapping) attrs.get(2).getMapping();
assertEquals("entity.ManyToMany2", hjmtmm.getTargetEntity());
}
use of org.eclipse.jpt.jpa.core.context.java.JavaPersistentType in project jbosstools-hibernate by jbosstools.
the class HibernatePersistenceUnitClassesComposite method buildLabelProvider.
private ILabelProvider buildLabelProvider() {
return new LabelProvider() {
@Override
public Image getImage(Object element) {
Image image = null;
if (element instanceof ClassRef) {
ClassRef classRef = (ClassRef) element;
JavaPersistentType persistentType = classRef.getJavaPersistentType();
if (persistentType != null) {
image = this.getImage(persistentType);
// image = JpaMappingImageHelper.imageForTypeMapping(persistentType.getMappingKey());
} else if (classRef instanceof PackageInfoRef) {
PackageInfoRef packageInfoRef = (PackageInfoRef) classRef;
if (packageInfoRef.getJavaPackageInfo() != null) {
image = JavaPlugin.getImageDescriptorRegistry().get(JavaPluginImages.DESC_OBJS_PACKAGE);
}
}
}
if (image != null) {
return image;
}
return HibernateJptUIPlugin.getDefault().getImage("warning");
}
@Override
public String getText(Object element) {
ClassRef classRef = (ClassRef) element;
String name = classRef.getClassName();
if (name == null) {
name = JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_CLASS_REF_NO_NAME;
}
return name;
}
};
}
use of org.eclipse.jpt.jpa.core.context.java.JavaPersistentType in project jbosstools-hibernate by jbosstools.
the class HibernateJpaModelTests method checkManyToMany2.
public void checkManyToMany2(ClassRef crs) {
JavaPersistentType javaPersistentType = crs.getJavaPersistentType();
JavaTypeMapping mapping = javaPersistentType.getMapping();
assertTrue(mapping instanceof HibernateJavaEntity);
HibernateJavaEntity entity = (HibernateJavaEntity) mapping;
HibernateJavaTable table = entity.getTable();
assertEquals("ManyToMany22", table.getDBTableName());
ArrayList<JavaSpecifiedPersistentAttribute> attrs = IterableTools.list(javaPersistentType.getAttributes());
assertTrue(attrs.size() == 3);
// id
assertTrue(attrs.get(0).getMapping() instanceof HibernateJavaIdMapping);
HibernateJavaIdMapping hjidm = (HibernateJavaIdMapping) attrs.get(0).getMapping();
HibernateJavaColumn hjc = (HibernateJavaColumn) hjidm.getColumn();
assertEquals("id", hjc.getDBColumnName());
// justData
assertTrue(attrs.get(1).getMapping() instanceof HibernateJavaBasicMapping);
HibernateJavaBasicMapping hjbm = (HibernateJavaBasicMapping) attrs.get(1).getMapping();
hjc = (HibernateJavaColumn) hjbm.getColumn();
assertEquals("justData", hjc.getDBColumnName());
// mtm
assertTrue(attrs.get(2).getMapping() instanceof HibernateJavaManyToManyMapping);
HibernateJavaManyToManyMapping hjmtmm = (HibernateJavaManyToManyMapping) attrs.get(2).getMapping();
assertEquals("entity.ManyToMany1", hjmtmm.getTargetEntity());
JavaSpecifiedJoinTableRelationshipStrategy jtJoiningStrategy = hjmtmm.getRelationship().getJoinTableStrategy();
JavaSpecifiedJoinTable joinTable = jtJoiningStrategy.getJoinTable();
assertTrue(joinTable instanceof HibernateJavaJoinTable);
HibernateJavaJoinTable hjjt = (HibernateJavaJoinTable) joinTable;
assertEquals("ManyToMany22_ManyToMany1", hjjt.getDBTableName());
}
use of org.eclipse.jpt.jpa.core.context.java.JavaPersistentType in project jbosstools-hibernate by jbosstools.
the class HibernateJpaModelTests method checkManyToMany1.
public void checkManyToMany1(ClassRef crs) {
JavaPersistentType javaPersistentType = crs.getJavaPersistentType();
JavaTypeMapping mapping = javaPersistentType.getMapping();
assertTrue(mapping instanceof HibernateJavaEntity);
HibernateJavaEntity entity = (HibernateJavaEntity) mapping;
HibernateJavaTable table = entity.getTable();
assertEquals("ManyToMany1", table.getDBTableName());
ArrayList<JavaSpecifiedPersistentAttribute> attrs = IterableTools.list(javaPersistentType.getAttributes());
assertTrue(attrs.size() == 3);
// id
assertTrue(attrs.get(0).getMapping() instanceof HibernateJavaIdMapping);
HibernateJavaIdMapping hjidm = (HibernateJavaIdMapping) attrs.get(0).getMapping();
HibernateJavaColumn hjc = (HibernateJavaColumn) hjidm.getColumn();
assertEquals("id1", hjc.getDBColumnName());
// justData
assertTrue(attrs.get(1).getMapping() instanceof HibernateJavaBasicMapping);
HibernateJavaBasicMapping hjbm = (HibernateJavaBasicMapping) attrs.get(1).getMapping();
hjc = (HibernateJavaColumn) hjbm.getColumn();
assertEquals("justData1", hjc.getDBColumnName());
// mtm
assertTrue(attrs.get(2).getMapping() instanceof HibernateJavaManyToManyMapping);
HibernateJavaManyToManyMapping hjmtmm = (HibernateJavaManyToManyMapping) attrs.get(2).getMapping();
assertEquals("entity.ManyToMany2", hjmtmm.getTargetEntity());
}
Aggregations