-->
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.  [ 3 posts ] 
Author Message
 Post subject: SEVERE: an assertion failure occured Table not found
PostPosted: Mon Feb 14, 2011 5:39 pm 
Beginner
Beginner

Joined: Sat Dec 01, 2007 4:34 pm
Posts: 20
My mapping seems to be causing the following error:
Code:
SEVERE: 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 SUBCATEGORY 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)


The table is there, so there shouldn't be an error...

The error appeared when I added the class Chapter which extends Category. If I remove it, everything works fine.

If I remove the references:
Code:
@ManyToOne and
  @JoinTable(name = "SUBCATEGORY",
             joinColumns = {@JoinColumn(name = "CHILDID")},
             inverseJoinColumns = {@JoinColumn(name = "PARENTID")})
  private Category parent;

  @ManyToMany
  @JoinTable(name = "SUBCATEGORY",
             joinColumns = { @JoinColumn(name = "PARENTID")},
             inverseJoinColumns = { @JoinColumn(name = "CHILDID")})


it works fine too... Could somebody please help?

sql
Code:
CREATE TABLE IF NOT EXISTS Category(
    CategoryId            bigint(4)     NOT NULL    auto_increment,
    Title                     varchar(30)   NOT NULL,
    CategoryLevel         bigint(1)     NOT NULL    DEFAULT '1',
    CategoryType         varchar(20)    NOT NULL    DEFAULT 'Category',
    PRIMARY KEY (CategoryId)
) ENGINE=INNODB;

CREATE TABLE IF NOT EXISTS Chapter(
    ChapterId             bigint(4)     NOT NULL    auto_increment,
    ChapterOrder          int(4)        NOT NULL    DEFAULT '0',
    BookId                bigint(4)     NOT NULL,
    PRIMARY KEY (ChapterId),
    FOREIGN KEY (ChapterId) REFERENCES Category(CategoryId) ON UPDATE CASCADE,
    FOREIGN KEY (BookId) REFERENCES Book(BookId) ON UPDATE CASCADE
) ENGINE=INNODB;

CREATE TABLE IF NOT EXISTS SubCategory(
    SubCategoryId     bigint(4)     NOT NULL   auto_increment,
    ParentId          bigint(4)     NOT NULL,
    ChildId           bigint(4)     NOT NULL,
    PRIMARY KEY (SubCategoryId),
    FOREIGN KEY (ParentId) REFERENCES Category(CategoryId) ON UPDATE CASCADE,
    FOREIGN KEY (ChildId) REFERENCES Category(CategoryId) ON UPDATE CASCADE
) ENGINE=INNODB;


Enitity Chapter
Code:
@Entity
@Table(name = "CHAPTER")
@PrimaryKeyJoinColumn(name="CHAPTERID", referencedColumnName="CATEGORYID")
public class Chapter extends Category {

  @Column(name = "CHAPTERORDER")
  private Long chapterOrder;
 
  @ManyToOne
  @JoinColumn(name = "BOOKID")
  private Book book;

  public Chapter() {super();}


Entity CAtegory
Code:
@Entity
@Table(name = "CATEGORY")
@Inheritance(strategy=InheritanceType.JOINED)
public class Category implements Serializable {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "CATEGORYID")
  private Long categoryId;

  @Column(name = "TITLE")
  private String title;
 
  @Column(name = "CATEGORYLEVEL")
  private Long categoryLevel;

  @Column(name = "CATEGORYTYPE")
  private String categoryType;

  @ManyToOne
  @JoinTable(name = "SUBCATEGORY",
             joinColumns = {@JoinColumn(name = "CHILDID")},
             inverseJoinColumns = {@JoinColumn(name = "PARENTID")})
  private Category parent;

  @ManyToMany
  @JoinTable(name = "SUBCATEGORY",
             joinColumns = { @JoinColumn(name = "PARENTID")},
             inverseJoinColumns = { @JoinColumn(name = "CHILDID")})
  private Set<Category> subCategoryList;


Entity SubCAtegory
Code:
@Entity
@Table(name = "SUBCATEGORY")
public class SubCategory implements Serializable {

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "SUBCATEGORYID")
  private Long subCategoryId;

  @Column(name = "PARENTID")
  private Long parentId;

  @Column(name = "CHILDID")
  private Long childId;


Top
 Profile  
 
 Post subject: Re: SEVERE: an assertion failure occured Table not found
PostPosted: Wed Mar 30, 2011 1:27 am 
Newbie

Joined: Wed Mar 30, 2011 1:13 am
Posts: 2
@ManyToOne
@JoinTable(name = "SUBCATEGORY",
joinColumns = {@JoinColumn(name = "CHILDID")},
inverseJoinColumns = {@JoinColumn(name = "PARENTID")})
private Category parent;

can you move this to getParent() method and verify whether it is working?


Top
 Profile  
 
 Post subject: Re: SEVERE: an assertion failure occured Table not found
PostPosted: Thu Mar 31, 2011 9:22 am 
Newbie

Joined: Wed Mar 30, 2011 1:13 am
Posts: 2
i changed annotations as below and it worked fine.

@ManyToOne(targetEntity=customer.Category.class)
@JoinTable(name = "SUBCATEGORY",
joinColumns = {@JoinColumn(name = "CHILDID",table="SUBCATEGORY", referencedColumnName="CATEGORYID")})
private Category parent;


@OneToMany(targetEntity=customer.Category.class)
@JoinTable(name = "SUBCATEGORY",
joinColumns = { @JoinColumn(name = "PARENTID",table="SUBCATEGORY",referencedColumnName="CATEGORYID") })
private Set<Category> subCategoryList = null;


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