-->
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.  [ 1 post ] 
Author Message
 Post subject: problem : @Inheritance "is specified on a non-root enti
PostPosted: Fri Nov 17, 2006 7:40 pm 
Newbie

Joined: Fri Nov 17, 2006 7:24 pm
Posts: 16
Thank you for reading my post.
I am learning hibernate using Pro Hibernate 3.0 book and i am reading chapter 4 with many pains.
I fixed many version incompatibilites between 3.0 and 3.2 in the sample codes but what i can not understand is the following problem.

Hibernate version: 3.2

Code:

package learn_hiber.chapter4;

import javax.persistence.*;

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name="BOOK_ID")
public class ComputerBook extends Book
{
    protected String softwareName;
   
    public String getSoftwareName()
    {
        return softwareName;
    }
    public void setSoftwareName(String softwareName)
    {
        this.softwareName = softwareName;
    }
}



problem is that the IDE says
Code:
@Inheritance "is specified on a non-root entity"


as you can see computerBook extends book class, and here is the book class


Code:

package learn_hiber.chapter4;

import java.util.*;
import javax.persistence.*;
import org.hibernate.annotations.AccessType;



@Entity
@AccessType("property")
public class Book
{
    protected String title;
   
    protected Publisher publisher;
    protected Set <Author> authors = new HashSet<Author>();
   
    protected int pages;
    protected int id;
   
    protected Date publicationDate;
       
    public int getPages()
    {
        return pages;
    }
    public void setPages(int pages)
    {
        this.pages = pages;
    }
    @Column(name="working_title",length=200,nullable=false)
    public String getTitle()
    {
        return title;
    }
    public void setTitle(String title)
    {
        this.title = title;
    }
   
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public int getId()
    {
        return id;
    }
    public void setId(int id)
    {
        this.id = id;
    }
   
    @Transient
    public Date getPublicationDate()
    {
        return publicationDate;
    }
    public void setPublicationDate(Date publicationDate)
    {
        this.publicationDate = publicationDate;
    }
   
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="publisher_id")
    public Publisher getPublisher()
    {
        return publisher;
    }
    public void setPublisher(Publisher publisher)
    {
        this.publisher = publisher;
    }
   
    @ManyToMany
    public Set<Author> getAuthors()
    {
        return authors;
    }
    public void setAuthors(Set<Author> authors)
    {
        this.authors = authors;
    }   
}


can you please tell me what is wrong with the code?
thanks


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

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.