Search in sources :

Example 1 with HibernateJavaEntity

use of org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity 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());
}
Also used : JavaSpecifiedJoinTable(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedJoinTable) HibernateJavaColumn(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumn) HibernateJavaJoinTable(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinTable) JavaTypeMapping(org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping) JavaPersistentType(org.eclipse.jpt.jpa.core.context.java.JavaPersistentType) HibernateJavaIdMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping) JavaSpecifiedJoinTableRelationshipStrategy(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedJoinTableRelationshipStrategy) HibernateJavaBasicMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaBasicMapping) JavaSpecifiedPersistentAttribute(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute) HibernateJavaTable(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTable) HibernateJavaManyToManyMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping) HibernateJavaEntity(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity)

Example 2 with HibernateJavaEntity

use of org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity 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());
}
Also used : HibernateJavaColumn(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumn) JavaTypeMapping(org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping) JavaPersistentType(org.eclipse.jpt.jpa.core.context.java.JavaPersistentType) JavaSpecifiedPersistentAttribute(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute) HibernateJavaIdMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping) HibernateJavaTable(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTable) HibernateJavaBasicMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaBasicMapping) HibernateJavaManyToManyMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping) HibernateJavaEntity(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity)

Example 3 with HibernateJavaEntity

use of org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity in project jbosstools-hibernate by jbosstools.

the class HibernateAbstractInheritanceComposite method initializeLayout.

@SuppressWarnings("unchecked")
@Override
protected void initializeLayout(Composite container) {
    int groupBoxMargin = getGroupBoxMargin();
    Composite subPane = addSubPane(container, 0, groupBoxMargin, 0, groupBoxMargin);
    // Strategy widgets
    this.addLabel(subPane, JptJpaUiDetailsMessages.INHERITANCE_COMPOSITE_STRATEGY);
    this.addStrategyCombo(container);
    // addLabeledComposite(
    // subPane,
    // JptUiDetailsMessages.InheritanceComposite_strategy,
    // addStrategyCombo(subPane),
    // JpaHelpContextIds.ENTITY_INHERITANCE_STRATEGY
    // );
    // Discriminator Value widgets
    PropertyValueModel<Boolean> dvEnabled = this.buildDiscriminatorValueEnabledHolder();
    // Combo discriminatorValueCombo = addEditableCombo(
    // subPane,
    // buildDiscriminatorValueListHolder(),
    // buildDiscriminatorValueHolder(),
    // buildDiscriminatorValueConverter(),
    // dvEnabled
    // );
    // Label discriminatorValueLabel = addLabel(
    // subPane,
    // JptUiDetailsMessages.InheritanceComposite_discriminatorValue,
    // dvEnabled
    // );
    this.addLabel(subPane, JptJpaUiDetailsMessages.INHERITANCE_COMPOSITE_DISCRIMINATOR_VALUE, dvEnabled);
    this.addEditableCombo(subPane, buildDiscriminatorValueListHolder(), buildDiscriminatorValueHolder(), buildDiscriminatorValueConverter(), dvEnabled);
    if (getSubject() instanceof HibernateJavaEntity) {
        new HibernateDiscriminatorColumnComposite((Pane<? extends HibernateJavaEntity>) this, container);
    } else {
        new DiscriminatorColumnComposite<Entity>(this, container);
    }
    // Primary Key Join Columns widgets
    addPrimaryKeyJoinColumnsComposite(addSubPane(container, 5));
}
Also used : AbstractEntityComposite(org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityComposite) Composite(org.eclipse.swt.widgets.Composite) DiscriminatorColumnComposite(org.eclipse.jpt.jpa.ui.internal.details.DiscriminatorColumnComposite) DiscriminatorColumnComposite(org.eclipse.jpt.jpa.ui.internal.details.DiscriminatorColumnComposite) HibernateJavaEntity(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity)

Example 4 with HibernateJavaEntity

use of org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity 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());
}
Also used : JavaSpecifiedJoinTable(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedJoinTable) HibernateJavaColumn(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumn) HibernateJavaJoinTable(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinTable) JavaTypeMapping(org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping) JavaPersistentType(org.eclipse.jpt.jpa.core.context.java.JavaPersistentType) HibernateJavaIdMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping) JavaSpecifiedJoinTableRelationshipStrategy(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedJoinTableRelationshipStrategy) HibernateJavaBasicMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaBasicMapping) JavaSpecifiedPersistentAttribute(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute) HibernateJavaTable(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTable) HibernateJavaManyToManyMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping) HibernateJavaEntity(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity)

Example 5 with HibernateJavaEntity

use of org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity 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());
}
Also used : HibernateJavaColumn(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumn) JavaTypeMapping(org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping) JavaPersistentType(org.eclipse.jpt.jpa.core.context.java.JavaPersistentType) JavaSpecifiedPersistentAttribute(org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute) HibernateJavaIdMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping) HibernateJavaTable(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTable) HibernateJavaBasicMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaBasicMapping) HibernateJavaManyToManyMapping(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping) HibernateJavaEntity(org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity)

Aggregations

HibernateJavaEntity (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity)5 JavaPersistentType (org.eclipse.jpt.jpa.core.context.java.JavaPersistentType)4 JavaSpecifiedPersistentAttribute (org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute)4 JavaTypeMapping (org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping)4 HibernateJavaBasicMapping (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaBasicMapping)4 HibernateJavaColumn (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumn)4 HibernateJavaIdMapping (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping)4 HibernateJavaManyToManyMapping (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaManyToManyMapping)4 HibernateJavaTable (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTable)4 JavaSpecifiedJoinTable (org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedJoinTable)2 JavaSpecifiedJoinTableRelationshipStrategy (org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedJoinTableRelationshipStrategy)2 HibernateJavaJoinTable (org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinTable)2 AbstractEntityComposite (org.eclipse.jpt.jpa.ui.internal.details.AbstractEntityComposite)1 DiscriminatorColumnComposite (org.eclipse.jpt.jpa.ui.internal.details.DiscriminatorColumnComposite)1 Composite (org.eclipse.swt.widgets.Composite)1