Actually, it appears that it doesn't like to mix the Inhertance annotation with the SecondaryTable Annotation. My full code is the following:
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name="USERS")
@SecondaryTable(name="GROUPS", join={@JoinColumn(name="USERNAME")})
public class User implements Serializable {
private String userName, group;
public User() {
userName = new String();
group = new String();
}
@Id
@Column(name="USER")
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Column(name="GROUPNAME", secondaryTable="GROUPS")
public String getGroup() {
return this.group;
}
public void setGroup(String group) {
this.group = group;
}
}
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name="MASTERUSERS")
@PrimaryKeyJoinColumn(name="USERNAME")
public class MasterUser extends User implements Serializable {
private String userType;
public MasterUser() {
userType = new String();
}
@Column(name="USERTYPE")
public String getUserType() {
return this.userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
}
If I make so that MasterUser is no longer a part of my project and thus class User is a standalone class, then the SecondaryTable works great. Also, if I remove the SecondaryTable annotations and put back the MasterUser so that it extends user, this also works great. However, when I put it all together, it fails with the following exception:
Code:
2005-09-30 14:48:22,625 ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: table not found
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:444)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:225)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1033)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:439)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:272)
at org.jboss.ejb3.Ejb3Deployment.initializeManagedEntityManagerFactory(Ejb3Deployment.java:476)
at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:219)
at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:34)
...
...
Is this a bug or am I doing something wrong?
Thanks,
~K