-->
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: Embedded and associated
PostPosted: Mon Dec 10, 2007 2:50 am 
Newbie

Joined: Wed Nov 28, 2007 10:04 pm
Posts: 10
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 4:48 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
at least it should be mappedBy="author" ie the name of the property on the other side.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 10, 2007 5:45 am 
Newbie

Joined: Wed Nov 28, 2007 10:04 pm
Posts: 10
I replace mappedBy = "person" with mappedBy = "author" but the error don't change.it still have that 3 error.


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.