Multiple Hexagonal architecture with sprint boot

I work on a spring boot application with spring data and hibernate.
I am using hexagonal architecture.
I have 2 hexagons:

  1. ConnexionManagment
  2. OrderManagment

Each hexagon interacts with the same table in the database called User.
In the OrderManagment hexagon I use User table because user have a list of orders
And in ConnexionManagment hexagon I use User table because I need to manage user information when the user subscribes and other things.

So in each hexagon U have added the same UserjpaEntity to interact with table user in the infrastructure layer.

Is it good practice to duplicate class userJpaEntity in each hexagon?
Or do I have to create a common hexagon and put all common classes in this hexagon?

To finish we can imagine other hexagon separate by functional domain which need to interact with the same table user in database.

So can you help me to find the best practice?
enter image description here
Thanks.

  • In my opinion the best way in this case is to create a common one and then use it where you need, because it is more related to infrastructure part and not bussines part.

    – 

Leave a Comment