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