I believe your many-to-many mapping is wrong. In class TCMTAMBITITERRITORIALI_COMUNI
you should have two simple associations for each of the other related tables.
The many-valued association should be in the other classes (Comuni and AmbitiTerritoriali) and both should point to TCMTAMBITITERRITORIALI_COMUNI
.
More info here: Many to many with Aurelius - #2 by wlandgraf