private void visitGenClassRefField(SpeedoField sf) throws SpeedoException {
logger.log(BasicLevel.DEBUG, "\t\tvisit field generic class reference '" + sf.name + "'.");
visitGenClassRefFieldExtension(sf);
visitFieldMappedBy(sf);
if (sf.mappedByReversefield) {
SpeedoField rf = sf.getReverseField();
logger.log(BasicLevel.DEBUG, "\t\tfield '" + sf.name
+ "' is mapped by reverse field: "
+ rf.getFQFieldName());
visitSpeedoClass(sf.getReferencedClass(), new VisitRequired(rf));
computeFieldFromReverse(sf);
// do not forget index in case of map indexed by field of the
// referenced class
visitGenClassIndex(sf);
return;
}
boolean joinCreated = sf.join == null;
if (joinCreated) {
//create the join between mainTable and the genClass table
sf.join = new SpeedoJoin();
//sf.moClass.addJoin(sf.join);
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG, "\t\t\tCreate SpeedoJoin");
}
}
if (sf.join.mainTable == null) {
sf.join.mainTable = sf.moClass.mainTable;
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG, "\t\t\tDefine the main table on join: " + sf.join.mainTable.name);
}
}
if (sf.join.extTable == null) {
//compute the table of the genclass with regards to the relation type
switch (sf.relationType) {
case SpeedoField.MANY_MANY_BI_RELATION:
SpeedoField rfield = sf.getReverseField();
if (rfield.join != null && rfield.join.extTable != null) {
sf.join.extTable = rfield.join.extTable;
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG, "\t\t\tUse table of reverse field: " + sf.join.extTable.name);
}