samedi 27 juin 2020

Java - Infinite Loop Factory Pattern Problem in Running Project

DataModel

EvaluationObject has a Many to Many relationship with itself that this makes Infinite Loop in run code by using Factory Pattern How to prevent Infinite Loop for this datamodel ?

sample :

public class EvaluationObjectDtoToEntityMapperFactory {
public EvaluationObjectDtoToEntityMapper get(){
     EvaluationObjectAssociationDtoToEntityMapper evaluationObjectAssociationDtoToEntityMapper = new EvaluationObjectAssociationDtoToEntityMapperFactory().get();
        EvaluationObjectTypeRepository evaluationObjectTypeRepository = new EvaluationObjectTypeRepositoryFactory().get();
        return new EvaluationObjectDtoToEntityMapperImpl(evaluationObjectAssociationDtoToEntityMapper,evaluationObjectTypeRepository);
    } 

}

sample :

public class EvaluationObjectAssociationDtoToEntityMapperFactory {
public EvaluationObjectAssociationDtoToEntityMapper get(){
        EvaluationObjectDtoToEntityMapper evaluationObjectDtoToEntityMapper = new EvaluationObjectDtoToEntityMapperFactory().get();
        return new EvaluationObjectAssociationDtoToEntityMapperImpl(evaluationObjectDtoToEntityMapper);
}

}

console: output

Aucun commentaire:

Enregistrer un commentaire