Je fais une référence ManyToOne dans une classe vers une autre.
Mais quand je lance mes tests Maven, j'ai l'erreur suivante :
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on fr.natoine.annotations_persistence.selection.SelectionHTML.selection_origin references an unknown entity: fr.natoine.annotations_persistence.document.Document
Le code de ma classe dans laquelle Document est un atribut :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package fr.natoine.annotations_persistence.selection;
 
import java.io.Serializable;
import java.util.Date;
 
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
import javax.persistence.InheritanceType;
import javax.xml.bind.annotation.XmlRootElement;
 
import fr.natoine.annotations_persistence.document.Document;
import fr.natoine.user_persistence.User;
 
@XmlRootElement
@MappedSuperclass
@Table(name = "SELECTION")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Selection implements Serializable
{
		@Id @GeneratedValue
	    @Column(name = "SELECTION_ID")
	    protected Long id;
		@Column(name = "SELECTION_URL_SOURCE")
		private String url_source;
		@Column(name = "SELECTION_BEGIN")
		private String begin;
		@Column(name = "SELECTION_END")
		private String end;
		@ManyToOne(cascade = CascadeType.ALL, targetEntity = Document.class)
		@JoinColumn(name = "DOCUMENT_ID")
		private Document selection_origin;
		@Column(name = "SELECTION_CONTEXT")
		private String context;
		@ManyToOne(cascade = CascadeType.ALL, targetEntity = User.class)
		@JoinColumn(name = "USER_ID")
		private User author;
		@Column(name = "SELECTION_CREATION")
		private Date creation;
 
		public Selection()
		{
		}
 
		public Long getId() {
			return id;
		}
		public String getUrl_source() {
			return url_source;
		}
		public void setUrl_source(String urlSource) {
			url_source = urlSource;
		}
		public String getBegin() {
			return begin;
		}
		public void setBegin(String begin) {
			this.begin = begin;
		}
		public String getEnd() {
			return end;
		}
		public void setEnd(String end) {
			this.end = end;
		}
		public Document getSelection_origin() {
			return selection_origin;
		}
		public void setSelection_origin(Document selectionOrigin) {
			selection_origin = selectionOrigin;
		}
		public User getAuthor() {
			return author;
		}
 
		public void setAuthor(User author) {
			this.author = author;
		}
 
		public String getContext() {
			return context;
		}
 
		public void setContext(String context) {
			this.context = context;
		}
 
		public Date getCreation() {
			return creation;
		}
 
		public void setCreation(Date creation) {
			this.creation = creation;
		}
}
Le code de la classe Document :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
package fr.natoine.annotations_persistence.document;
 
import java.util.Date;
 
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
 
@XmlRootElement
@MappedSuperclass
@Table(name = "DOCUMENT")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Document implements Serializable
{
	@Id @GeneratedValue
    @Column(name = "DOCUMENT_ID")
	private Long id;
	@Column(name = "DOCUMENT_TITLE")
	private String title;
	@Column(name = "DOCUMENT_URL")
	private String url;
	@Column(name = "DOCUMENT_DATE_CREATION")
	private Date creation_in_context;
	@Column(name = "DOCUMENT_CONTEXT")
	private String context;
 
 
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public Date getCreation_in_context() {
		return creation_in_context;
	}
	public void setCreation_in_context(Date creationInContext) {
		creation_in_context = creationInContext;
	}
	public String getContext() {
		return context;
	}
	public void setContext(String context) {
		this.context = context;
	}
	public Long getId() {
		return id;
	}
 
}
Mon mapping de classes dans mon fichier persistence.xml :
<mapping class="fr.natoine.annotations_persistence.selection.Selection"/>
<mapping class="fr.natoine.annotations_persistence.selection.SelectionHTML"/>
<mapping class="fr.natoine.annotations_persistence.annotation.Annotation"/>
<mapping class="fr.natoine.annotations_persistence.annotation.AnnotationDocument"/>
<mapping class="fr.natoine.annotations_persistence.annotation.AnnotationSelection"/>
<mapping class="fr.natoine.annotations_persistence.document.Document"/>
<mapping class="fr.natoine.annotations_persistence.document.DocumentHTML"/>
Est-ce que quelqu'un peut m'aider svp