Hi guys,
is this problem solved? I'm facing almost the same one. (Hibernate version 3.3.2.GA)
This is my DB-schema:

... and my classes:
Code:
public class EntityAuditRecord {
private Long id;
private Set<Diff> changes;
// other relevant stuff here
}
public class Diff {
private String propertyName;
private Object oldValue;
private Object newValue;
// setters, getters and the rest stuff here
}
... and here's my mapping:
Code:
<hibernate-mapping>
<class name="EntityAuditRecord" table="ENTITY_AUDIT">
<!-- ID and the rest fields' mapping here -->
<set name="changes" table="ENTITY_DIFF">
<key column="ENTITY_AUDIT_ID" />
<composite-element class="Diff">
<property name="propertyName" column="PROPERTY" />
<property name="oldValue" column="OLD_VALUE" />
<property name="newValue" column="NEW_VALUE" />
</composite-element>
</set>
</class>
</hibernate-mapping>
When I try to run it I get the following exception:
Quote:
Caused by: org.hibernate.MappingException: collection element mapping has wrong number of columns: com.idc.worldwide.keystones.service.core.audit.domain.EntityAuditRecord.changes type: component[propertyName,oldValue,newValue]
at org.hibernate.mapping.Collection.validate(Collection.java:302)
at org.hibernate.mapping.Set.validate(Set.java:42)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1153)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 56 more
Table
ENTITY_DIFF contains 4 columns (1 foreign key and 3 simple properties) and all of them are mapped.
I don't want to create a separate entity for
Diff class and map it as
<one-to-many>. According to the Hibernate Reference my mapping supposes to be correct. (See the first example here
http://docs.jboss.org/hibernate/core/3. ... ollections)
How can I make it working? Am I missing something?
Thank you!