As a system architecture, should I encourage the team to use cascade characteristic of spring JPA?

18 Views Asked by At

I intend to forbid the cascades usage, we could do the cascade operation by additonal coding in the specific suituation if needed. Below are what I think about this:

  1. cascade query. In most cases, we need not load a entity with it's all related child entities by only one request, but request the main entity at first, then if the client needs display/handle the related children, request them secondly. so what we need to do seperate the services into 2 different method. The second view point, a auto cascade configuration on entity perhaps good to one scenario, but in another scenario, it may cause additional unnecessary performance lost. The third, the "keep open in view" option may be forced to open by a possible lazy fetch setting, its very harmful to the system performance.

  2. cascade insert/update/delete. Honestly to say, I think its too hard for the team to handle this characteristic, we must deal with it very carefully to avoid the potential unexpected operations.

As a beginner to the spring JPA/hibernate, I'm very glad to share my idea, and need your kindly suggestion based on your experience!!!

I want to talk about/know the best practises on how to use spring JPA/hibernate.

0

There are 0 best solutions below