-->
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.  [ 6 posts ] 
Author Message
 Post subject: Joined Inheritance & SecondaryTables doesn't work
PostPosted: Wed May 17, 2006 8:37 am 
Newbie

Joined: Tue May 16, 2006 12:49 pm
Posts: 8
Hi!

I can't get the following code to run:
Code:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "Customers")
@SecondaryTable(name = "Addresses")
public class Customer extends UpdatableDbEntry {
    // ...

    @Column(table = "Addresses", name = "STR_FIRSTNAME")
    private String firstName;

}


I made some debugging and it seems like the JoinedSubClassEntityPersister just doesn't realize that there's a second table to consider; i.e. the field tableNames just contains the Customers table and also, the field propertyTableNumbers indicates that the firstName should be in that table also.
If I change the InheritanceType to SINGLE_TABLE or PER_CLASS, the persister works and recognized the secondary table (this is not applicable for obvious reasons, just to proof that I used the annotations correctly and the table exists etc.).

My main question is: is this a bug or isn't this covered by the EJB3.0 spec at all? If there would be a workaround, I'd appreciate that info also. ;)

Sebastian

Hibernate version:
3.2.0.cr1 / Annotations Beta 10
Mapping documents:
%
Code between sessionFactory.openSession() and session.close():
&
Full stack trace of any exception that occurs:
org.hibernate.AssertionFailure: Table UKASH.Addresses 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:218)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1180)
Name and version of the database you are using:
%
The generated SQL (show_sql=true):
%
Debug level Hibernate log excerpt:
%


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 19, 2006 6:02 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
A runnable minial test case would be apreciated. Please post a JIRA issue.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: JIRA
PostPosted: Mon May 29, 2006 8:55 am 
Newbie

Joined: Tue May 16, 2006 12:49 pm
Posts: 8
What's a JIRA issue? How do I post it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 12:15 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is our issue tracking system http://opensource.atlassian.com/projects/hibernate/secure/Dashboard.jspa

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Joined Inheritance & SecondaryTables doesn't work
PostPosted: Fri Jun 23, 2006 6:23 pm 
Newbie

Joined: Wed Jun 21, 2006 8:13 pm
Posts: 2
Speaking of SecondaryTables and Inheritance,
is it possible to define a secondary table for a superclass. When I try to initialize the subclass, hibernate says it can't find the secondary table, but it works fine if I'm just using the superclass by itself.



Superclass
Code:
@Entity
@Table(name="test")
@Inheritance(strategy = InheritanceType.JOINED)
@SecondaryTable(name="test_secondary")
public class BasicClass {

    private String id;
    private String v1;
    private String extv1;
     @Id
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getV1() {
        return v1;
    }

    public void setV1(String v1) {
        this.v1 = v1;
    }

   @Basic(fetch = FetchType.LAZY)
   @Column(table = "test_secondary")
    public String getExtv1() {
        return extv1;
    }

    public void setExtv1(String extv1) {
        this.extv1 = extv1;
    }

Subclass
Code:
@Entity
public class BasicSubclass extends BasicClass {
    private String v3;

    public String getV3() {
        return v3;
    }

    public void setV3(String v3) {
        this.v3 = v3;
    }
}


Error
Code:
23 Jun 2006 15:18:28 - ERROR org.hibernate.AssertionFailure .main() - 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 test_secondary 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:1176)
   at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:144)
   at hibernate.BasicClass.main(BasicClass.java:57)
   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:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
org.hibernate.AssertionFailure: Table test_secondary 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:1176)
   at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:144)
   at hibernate.BasicClass.main(BasicClass.java:57)
   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:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Exception in thread "main" java.lang.ExceptionInInitializerError
   at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:148)
   at hibernate.BasicClass.main(BasicClass.java:57)
   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:585)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.hibernate.AssertionFailure: Table test_secondary 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:1176)
   at hibernate.HibernateUtil.<clinit>(HibernateUtil.java:144)
   ... 6 more



Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 5:22 am 
Newbie

Joined: Tue May 16, 2006 12:49 pm
Posts: 8
Posted a JIRA issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.