For an object with a list of components:
class Entity{
Long id;
String name;
List<Component> components = new ArrayList<Component>();
}
class Component{ Object value; }
Configuration:
<hibernate-mapping>
<class name="Entity" table="entity">
<id name="id" access="field" column="id"/>
<property name="name" access="field" unique="true"/>
<list name="components" access="field" table="COMPONENTS" lazy="true">
<key column="id"/>
<list-index column="idx"/>
<composite-element class="Component">
<property name="value" access="field"/>
</composite-element>
</list>
</class>
</hibernate-mapping>
Is it possible to update one component from the list using the HQL instruction, for example
update Entity e set e.components[:index].value = :value where e.name = :name
what does not work?
Alternatively, you can configure lazy loading of the list of components so that the first access:
entity.components.get(0).value = "..";
not loading the whole list?
Edit: The
configuration lazy="extra"works for selection (only loads the component for updating), but does not update the changed component.
source
share