Code:
Place p = new Place ();
p.setName(form.getName());
Phone phone = form.getPhone();
HashSet set = new HashSet();
set.add(phone );
p.setPhoneNumbers(set);
SessionFactory sf = (SessionFactory)httpServletRequest.getSession().getAttribute("session.factory");
System.out.println(httpServletRequest.getSession());
try
{
Session s = sf.openSession();
s.saveOrUpdate(phone);
s.saveOrUpdate(p);
s.close();
}
catch(HibernateException he)
{
//
}
and, from the hbm file:
Code:
<class name="a.b.Place" table="places">
<id name="id">
<generator class="native"/>
</id>
<property name="name" type="string"/>
<set name="phoneNumbers" lazy="false" table="pphones" cascade="all">
<key column="place_id"/>
<many-to-many class="a.b.Phone" column="phone_id"/>
</set>
</class>
The problem is that the mapping table, pphones, has zero records after my saves...