I am getting a mappedBy reference an unknown target entity property in my code but I just done see where the problem is. Ive looked it over so many times i'm certain its starring me in the face but I just done see it.
My error is
mappedBy reference an unknown target entity property: com.jms.helloworld.domain.EventType.eventmasters in com.jms.helloworld.domain.EventMasters.eventType
package com.jms.helloworld.domain;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "EVENTTYPES")
@NamedQueries({
@NamedQuery(name="EventType.findAllWithDetail",
query="select distinct e from EventType e left join fetch e.events n ")
})
public class EventType implements Serializable {
private int id;
private String name;
private EventMasters eventmasters;
private Set<Events> events = new HashSet<Events>();
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(mappedBy = "eventtype", cascade=CascadeType.ALL, orphanRemoval=true)
public Set<Events> getEvents() {
return events;
}
public void setEvents(Set<Events> events) {
this.events = events;
}
@ManyToOne
@JoinColumn(name = "EVENTMASTER_ID")
public EventMasters getEventMasters() {
return eventmasters;
}
public void setEventMasters(EventMasters eventmasters) {
this.eventmasters = eventmasters;
}
}
and
package com.jms.helloworld.domain;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name="EVENTMASTERS")
/*
@NamedQueries({
@NamedQuery(name="Menus.findAllWithID",
query="select distinct c from Menus c left join fetch c.category t left join fetch t.items h" +
" where c.site_id = :id")
})
*/
public class EventMasters implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int id;
private String name;
private Sites sites;
private Set<EventType> eventtype = new HashSet<EventType>();
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "ID")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToOne
@JoinColumn(name = "SITE_ID")
public Sites getSites() {
return sites;
}
public void setSites(Sites sites) {
this.sites = sites;
}
@OneToMany(mappedBy = "eventmasters", cascade=CascadeType.ALL, orphanRemoval=true)
public Set<EventType> getEventType() {
return eventtype;
}
public void setEventType(Set<EventType> eventtype) {
this.eventtype = eventtype;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…