ConceptService concept creation

I am facing this weird error when i am creating concepts using a recursive utility which reads from a csv file. The scenario is as follows:

Concept A has two child answers B and C present in the file .

When A is being loaded, it can’t find B and C, hence i make a recursive call to store B and C. when the recursive call returns to the parent, i get an error the child don’t exist yet.

During the recursive calls made to B and C, after the are created. I check using conceptService.getConceptbyuuid() to see whether B and C exist and they do. But when the call returns to parent, the children don’t exist.

I tried flushing the session as soon as i create concepts. But it still doesn’t work. I am using ConceptService.SaveConcept(concept) to save a concept.

Any pointers would be really helpful.

Can you try instantiating the children, don’t save them separately instead add them to the parent and save the parent, the save should cascade to the children.

Thanks for the reply. I tried doing that but when it comes back to the parent concept, it tries to add answers and since answers are not yet saved, it gives a null pointer exception.

I’m not sure how you are doing it, can you please share you code so we can take a look?


I was able to debug the problem. It was a code issue. Thanks a lot for your help.

Great! Can you please give more details of what the actual issue was and how you solved it, it can be very useful in the future for somebody else running into a similar issue.

Sure. Changed the approach. i just iterated thru the datastructure twice. First time i create concepts and second time i add answers.


Parent -> Child

A -> (B,C)



In the first iteration. I ignore the concept answers, so just create A,B and C line by line. Iteration 2, i connect answers to the parent. since all concepts are present by this time.

Makes sense, thanks!