It may seem tedious, but i have problem with graphs. i have simple one to many relationship. This is a part from the xml mapping:
Code:
<class name="ObjectType" table="ObjectType">
<id name="id" column="objecttype_id">
<generator class="assigned"/>
</id>
<property name="name" column="name"/>
<set name="attributes" inverse="true" lazy="true" order-by="name" cascade="save-update">
<key column="objecttype_id"/>
<one-to-many class="Attribute"/>
</set>
</class>
<class name="Attribute" table="Attribute">
<id name="id" column="attribute_id">
<generator class="assigned"/>
</id>
<property name="name" column="name"/>
<many-to-one class="ObjectType" name="objectType" column="objecttype_id"/>
</class>
and i have the following code:
Code:
ObjectType objectType = manager.createObjectType(); // just new() operator
String otName = "ObjectTypeName";
objectType.setName(otName);
Collection attributes = objectType.getAttributes();
Attribute attribute = manager.createAttribute();
attribute.setName("A1");
attributes.add(attribute);
manager.store(objectType);
Manager just saves object this way:
Code:
Session session = sessionFactory.openSession();
session.save(object);
session.flush();
session.close();
and while saving i have 1 insert for object type and 1 _update_ for attribute! i dont know why.
what is wrong? if it's neccessary i can provide hibernate log.