JpaJoinColumn jpaJoin = (JpaJoinColumn) path.getObject();
JpaRelationship jpaRelationship = (JpaRelationship) path.getObjectParent();
JpaEntity targetEntity = context.getEntityMap().entityForClass(
jpaRelationship.getTargetEntityName());
JpaId jpaTargetId = targetEntity.getAttributes().getIdForColumnName(
jpaJoin.getReferencedColumnName());
if (jpaTargetId == null) {
throw new IllegalArgumentException("Null id "
+ targetEntity.getName()
+ "."
+ jpaJoin.getReferencedColumnName());
}
DbRelationship dbRelationship = (DbRelationship) targetPath.getObject();
// add FK
DbAttribute src = new DbAttribute(jpaJoin.getName());
// TODO: andrus, 5/2/2006 - infer this from Jpa relationship
src.setMandatory(false);
src.setMaxLength(jpaTargetId.getColumn().getLength());
src.setType(jpaTargetId.getDefaultJdbcType());
Entity srcEntity = dbRelationship.getSourceEntity();
srcEntity.addAttribute(src);
// add join
DbJoin join = new DbJoin(dbRelationship, src.getName(), jpaTargetId
.getColumn()
.getName());
dbRelationship.addJoin(join);
return false;