Replicating test case can be found in hibernate-core:
org.hibernate.test.manytomany.ManyToManyBidirectionalTest