I am getting the following exception when trying to map a set of embeddable types into an entity:
Code:
org.hibernate.MappingException: Could not determine type for: java.util.Set, for columns: [org.hibernate.mapping.Column(accountParties)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253)
at org.hibernate.mapping.Property.isValid(Property.java:185)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:440)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
My entity looks like this:
Code:
@Entity
public class Account implements Serializable {
...
private Set<AccountParty> accountParties =
new HashSet<AccountParty>();
@CollectionOfElements(targetElement = AccountParty.class)
@JoinTable(name="Account_AccountParties")
public Set<AccountParty> getAccountParties() {
return accountParties;
}
public void setAccountParties(Set<AccountParty> accountParties) {
this.accountParties = accountParties;
}
}
As you can see, I have put @CollectionOfElements on the getter method of accountParties. Also I have specified the set as Set<AccountParty>. So why is hibernate not able to determine the type for java.util.Set? My embeddable class looks like this:
Code:
@Embeddable
public class AccountParty implements Serializable {
private Party party;
@ManyToOne(targetEntity=Party.class)
public Party getParty() {
return party;
}
public void setParty(Party party) {
this.party = party;
}
}
Any help would be much appreciated?
Thanks.
Naresh