I have 2 class are Person and Book. a book will have an author. Book will have relationship one - one with Person and Person will have relationship one - many with Book. 2 class as below :
Person.java
package quickstart.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import org.hibernate.mapping.Set;
import org.hibernate.search.annotations.*;
@Entity
@Indexed(index="indexes/Person")
public class Person {
@Id
@GeneratedValue
@DocumentId
private Integer id;
@Field(index=Index.TOKENIZED, store=Store.NO)
private String firstName;
@Field(index=Index.TOKENIZED, store=Store.NO)
private String lastName;
@ContainedIn
@OneToMany(mappedBy = "Person")
private Set<Book> books;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
and Book.java
package quickstart.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.CascadeType;
import org.hibernate.search.annotations.*;
import quickstart.model.Person;
@Entity
@Indexed(index="indexes/Book")
public class Book {
@Id
@GeneratedValue
@DocumentId
private Integer id;
@Field(index=Index.TOKENIZED, store=Store.NO)
private String name;
@OneToOne( cascade = { CascadeType.PERSIST, CascadeType.REMOVE } )
@IndexedEmbedded
private Person author;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Person getAuthor() {
return author;
}
public void setAuthor(Person author) {
this.author = author;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
but it throw 3 errors as below:
-MappedBy specified for books does not exist on the target entity class
-Target null.class is not an entity
-The type Set is not generic; it cannot be parameterized with arguments <Book>
can you show me the problem????
thx
|