use of org.eclipse.jpt.jpa.db.Table in project jbosstools-hibernate by jbosstools.
the class NamingStrategyMappingTools method buildDbJoinTableDefaultName.
protected static String buildDbJoinTableDefaultName(Relationship relationshipReference) {
Table owningTable = relationshipReference.getTypeMapping().getPrimaryDbTable();
if (owningTable == null) {
return null;
}
RelationshipMapping relationshipMapping = relationshipReference.getMapping();
if (relationshipMapping == null) {
return null;
}
Entity targetEntity = relationshipMapping.getResolvedTargetEntity();
if (targetEntity == null) {
return null;
}
Table targetTable = targetEntity.getPrimaryDbTable();
if (targetTable == null) {
return null;
}
String name = owningTable.getName() + '_' + targetTable.getName();
return owningTable.getDatabase().convertNameToIdentifier(name);
}
use of org.eclipse.jpt.jpa.db.Table in project jbosstools-hibernate by jbosstools.
the class ForeignKeyImpl method validateForeignKeyName.
private void validateForeignKeyName(List<IMessage> messages, String name, TextRange range) {
if (name == null || name.trim().length() == 0) {
messages.add(HibernateJpaValidationMessage.buildMessage(IMessage.HIGH_SEVERITY, Messages.NAME_CANT_BE_EMPTY, getResource(), range));
} else {
AttributeMapping mapping = (AttributeMapping) getParent();
Table table = mapping.getTypeMapping().getPrimaryDbTable();
if (!mapping.validatesAgainstDatabase() || table == null) {
return;
}
Iterator<org.eclipse.jpt.jpa.db.ForeignKey> fks = table.getForeignKeys().iterator();
while (fks.hasNext()) {
org.eclipse.jpt.jpa.db.ForeignKey fk = fks.next();
if (name.equals(fk.getIdentifier())) {
return;
}
}
messages.add(HibernateJpaValidationMessage.buildMessage(IMessage.HIGH_SEVERITY, Messages.UNRESOLVED_FOREIGN_KEY_NAME, getResource(), range));
}
}
Aggregations