As hlfsousa said, you should understand that the session is a cache for proxified objects.
So, you could do
Code:
session.beginTransaction();
A a = session.load(...);
B b = session.load(...);
a.getBSet().add(b); // and/or b.getASet().add(a);
session.getTransaction().commit();
Instead of trying to save your object, there's no need to (re)do it.
But, there's no reason why the save raises an exception in your code. When you ask for the save of an object that's already a reference present in the cache, nothing is just done...
So could you be a bit more precise about what you do, your mappings, etc...