Hello Martin;
I had just come out of such set of problems with one-to-one and one-to-many. You need to make the mapping bi-directional.
In your add method for class A should be
bSist would be any kind of collection that you are using to persist the b objects
addChild(B b){
b.setA(this);
if(bSet==null){
bSet = new HashSet();
}
bList.add(b);
}
change your a mapping to look something like this: added inverse= "true"
<hibernate-mapping>
<class name="de.bebit.blackbook.test.A" table="test_A">
<id name="id">
<generator class="native"/>
</id>
<set name="children" table="test_A_B" cascade="all" inverse="true">
<key column="a_id"/>
<many-to-many column="b_id" class="de.bebit.blackbook.test.B"/>
</set>
</class>
</hibernate-mapping>
also try setting the unsaved-value="any" for in mapping of B such as
add a setter and getter for "a"
<hibernate-mapping>
<class name="de.bebit.blackbook.test.B" table="test_B">
<id name="id" unsaved-value="any">
<generator class="native"/>
</id>
<many-to-many cascade="none" name ="a" column="b_id" insert ="false" update = "false" class="de.bebit.blackbook.test.A"/>
</class>
</hibernate-mapping>
for reference you can look at an example for many-to-many given in this tutorial. I belive doing all these should solve your problem
http://www.warfrog.com/hibernatetutorial2/