Here is the hierarchy structure:
Code:
@MappedSuperclass
@Entity
@Table(name = "group")
public class GroupInfo implements Serializable {
protected Integer id;
//...
@Basic
@Id
@javax.persistence.SequenceGenerator(name = "group_id_sequence", sequenceName = "se_group_id_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "group_id_sequence")
@Column(name = "id")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
// ...
}
Its subclass, Group, is defined as the following:
Code:
@Entity
@Table(name = "group")
public class Group extends GroupInfo {
// ....
private Set<Membership> memberships;
// ...
@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.group")
protected Set<Membership> getMembershipsInternal() {
if (memberships == null)
memberships = new HashSet<Membership>();
return memberships;
}
// ...
}
where the Membership class is defined as:
Code:
@Entity
@Table(name = "membership")
@AssociationOverrides({
@AssociationOverride(name = "pk.user", joinColumns = @JoinColumn(name = "user_fk")),
@AssociationOverride(name = "pk.group", joinColumns = @JoinColumn(name = "group_fk"))
})
public class Membership implements Serializable {
// ...
private UserGroupCompoundKey pk;
// ...
@EmbeddedId
public UserGroupCompoundKey getPk() {
return pk;
}
// ...
}
the compound key is defined as:
Code:
@Embeddable
public class UserGroupCompoundKey implements Serializable {
private UserInfo user;
private GroupInfo group;
//...
@ManyToOne
public GroupInfo getGroup() {
return group;
}
//...
}
The above can pass the deployment. Now, I need to have one more top super class as:
Code:
@MappedSuperclass
@Entity
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS)
public class AbstractSecureObject implements Serializable {
@Basic
@Id
@GeneratedValue
protected Integer id;
//...
}
And I need to modify the GroupInfo class accordingly.
Code:
public class GroupInfo extends AbstractSecureObject {
// protected Integer id;
// remove the getter and setter of id
}
With the above changes, I run into an exception:
Quote:
...
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: group, for columns: [org.hibernate.mapping.Column(memberships)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:292)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:276)
at org.hibernate.mapping.Property.isValid(Property.java:207)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:458)
at org.hibernate.mapping.RootClass.validate(RootClass.java:215)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1135)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1320)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
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)
... 66 more
I can't see how this exception relates with the hierarchy change.
Can someone help me out of this problem?