ManyToMany with another class as the junction table. is it possible?

I have two classes, that I want them to be ManyToMany relationship.
But not only that, I want to have a third class as a junction table, so that I could set its property “tipoContratante” , because each relationship could be of four kinds.
Is it possible using hibernate? Or would be another way to achieve the same?

@Entity
public class Contrato {
    @Id
    @GeneratedValue
    private long id;
   
   @OneToMany(mappedBy="contrato",cascade=CascadeType.ALL,orphanRemoval = true)
    private List<Contratante> contratantes = new ArrayList<Contratante>();

}
@Entity
public class Contratante {

    @Id
    @GeneratedValue
    private long id;
    @Enumerated(EnumType.STRING)
    private tipoContratante tipo;
    
 
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "contrato_id")
    private Contrato contrato;
    
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "pessoa_id")
    private Pessoa pessoa;
    
}
@Entity
public class Pessoa {

    @OneToMany(mappedBy="pessoa",cascade = CascadeType.ALL)
    private List<Contratante> contratos = new ArrayList<Contratante>();
}

Yes, it’s possible. The mapping looks fine. Is there a problem with it?

When I try to save the Contrato() type object, with the
Contrato.contratantes populated with objects,
hibernate is not inserting them into the table Contratante.
It is just inserting the data of Contrato Entity.
I want it may insert the data in the Contratante table and in Pessoa table, (cascade)

Sorry… I just got what was the problem… When I was testing it, i forgot to insert at least one property of the Pessoa type objects…
I tried now, and it just worked.
Because I am just learning how to use hibernate, i was thinking I was doing something wrong… But the error was not the mapping.
Thank you anyway…