-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: @SecondaryTable: assertion failure
PostPosted: Wed Sep 28, 2005 2:52 pm 
Newbie

Joined: Tue Jul 19, 2005 1:37 pm
Posts: 5
I have the following EJB Entity:

Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name="USERS")
@SecondaryTable(name="GROUPS", join={@JoinColumn(name="USERNAME", referencedColumnName="USERNAME")})
public abstract 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;
   }
}



For some reason, I get the following exception, The table does indeed exist.

Code:
[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(JoinedSubclassEntityPers
ister.java:444)
   at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:225)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
...
...



Any help would be much appreciated!

Thanks,
~K [/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:38 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't think I support referenced column name on non PK columns for secondary tables. Add a JIRA issue. This won't be top priority though

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 2:42 pm 
Newbie

Joined: Tue Jul 19, 2005 1:37 pm
Posts: 5
emmanuel wrote:
I don't think I support referenced column name on non PK columns for secondary tables. Add a JIRA issue. This won't be top priority though


Hi Emmanuel,
Thank you very much for your response. I also want to thank you for all your help as I have read many posts where you replied thoroughly and quickly!

~K


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 3:00 pm 
Newbie

Joined: Tue Jul 19, 2005 1:37 pm
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 7:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Post a unit test to JIRA.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.