-->
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: ANN-376: ManyToOne mapping; JoinedSubclassEntity; Join Table
PostPosted: Thu Nov 15, 2007 6:08 am 
Newbie

Joined: Thu Nov 15, 2007 5:15 am
Posts: 1
Hibernate version: the latest GA releases, Hibernate Core 3.2.5.ga, Hibernate Annotations 3.3.0 GA, Hibernate EntityManager 3.3.1 GA. (The problem was repeated also under the Hibernate Core 3.2.2)

I encountered the same issue as ANN-376, as far as I can tell. In the bug it says it's a duplicate but doesn't mention what it is a duplicate of. A search on Google and related forums only brought this bug, and I couldn't find the supposed duplicate, or any other documentation of this error.

In my case, the problem did not occur at first, the hibernate was working fine until we added a ManyToOne relation (which is mapped in the reverse direction). So long as the relation was based on a join column alone, it worked fine:

Code:
@Entity
@Table(name = "X")
@Inheritance(strategy = InheritanceType.JOINED)
Class X extends R {

   @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
   @JoinColumn(name = "XrelToY")
   public Y getY() {..}
}

@Entity
@Table(name = "Y")
@Inheritance(strategy = InheritanceType.JOINED)
Class Y extends R {

   @OneToMany(mappedBy = "y")
   public Set<X> getAllX()
   {..}
}


But once we changed the mapping to a join table (as follows) we got the error (below).

Code:
@Entity
@Table(name = "X")
@Inheritance(strategy = InheritanceType.JOINED)
Class X extends R {

   @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
   @JoinTable(name = "XrelationToY", joinColumns = @JoinColumn(name = "X_id"), inverseJoinColumns = @JoinColumn(name = "Y_id"))
   public Y getY() {..}
}


@Entity
@Table(name = "Y")
@Inheritance(strategy = InheritanceType.JOINED)
Class Y extends R {

   @OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
   @JoinTable(name = "XrelationToY", joinColumns = @JoinColumn(name = "X_id"), inverseJoinColumns = @JoinColumn(name = "Y_id"))
   public Set<X> getAllX()
   {..}
}


We also tried several variations (having the inverse relation mappedBy, switching the direction of the join and inverse columns) - all with the same result.
At first we thought there may be a case-sensitivity issue but lowercasing all tablenames ruled that out. The same error kept coming back.

Full stack trace of any exception that occurs:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:

Code:
4157 [main] DEBUG org.hibernate.persister.entity.AbstractEntityPersister  -  Identity insert: insert into R (A, B, C, D) values (?, ?, ?, ?)
4204 [main] 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 XrelationToY not found
   at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:458)
   at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:237)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
   at com.dataessence.sandbox.domain.financial.vocabulary.TestVocabulary.testEntityManager(TestVocabulary.java:28)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Name and version of the database you are using: MySQL 5.0.22


Thanks so much for your time, hope it's clear.
For now we are backing off to a join column, but it seems to me that the bug mentioned above is still in existence.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 21, 2008 10:50 am 
Newbie

Joined: Wed Feb 27, 2008 10:47 am
Posts: 6
I have the same problem,
Have you found a solution?
Thanks a lot


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 3:27 pm 
Newbie

Joined: Tue Jun 03, 2008 3:19 pm
Posts: 2
Just wanted to add a "me too", except I am configuring things in XML, and not annotations. If I join a table without specifying properties, I receive no errors.

Code:
<subclass name="mydomain.SubClass" extends="mydomain.SuperClass"
   discriminator-value="FOO">

   <join table="SubClass">
      <key column="id" />
      <property name="foo" column="Foo" type="string" not-null="true" />
      <property name="bar" column="Bar" type="string" not-null="true" />
   </join>
</subclass>


If I add the properties, I get
Caused by:
org.hibernate.AssertionFailure: Table SubClass not found
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(JoinedSubclassEntityPersister.java:458)
at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:237)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2008 9:49 am 
Newbie

Joined: Wed Jun 04, 2008 9:46 pm
Posts: 5
I also have this problem. It would be great to at least have a point to some place where this is discussed with some completeness.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2008 9:50 am 
Newbie

Joined: Wed Jun 04, 2008 9:46 pm
Posts: 5
I also have this problem. It would be great to at least have a pointer to some place where this is discussed with some completeness.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.