Skip to content

cassiusvm/mapstructcycle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapStruct Cycle

In mapstruct-mapping-with-cycles the cycle stops at data access level but not at json level when you try to convert the dto to json because the dto's still have the dependencies on each other.

The main branch shows the use case.

The branch attempttosolve1 use the mapstruct-mapping-with-cycles strategy, it solves the cycle at data access level but not at json level. Try: http://localhost:8080/mother

The branch attempttosolve2 use the "Update 2" strategy from Prevent Cyclic references when converting with MapStruct, it solves the both the cycles at data access level and at json level.

Unfortunately, the "Update 2" strategy is some cumbersome when you have a more complex use case, for example: Father->Child->Pet.

I solved the cycle at json level on attempttosolve1 by using @AfterMapping ans setting the ofending dependencies to null.

About

Application about MapStruct mappings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages