Hello i cannot find my mistake in here.
Code:
package com.example;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "events")
public class events implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int eventid;
@Column(name = "eventdate")
private Date eventdate;
@Column(name = "eventplace")
private String eventplace;
@Column(name = "eventstatus")
private boolean status;
@ManyToMany(mappedBy = "eventSet")
private Set<user> userliste;
private sportarten sportart;
public events() {
}
public events(String name) {
setEventplace(name);
}
public events(events search, HashSet<user> hashSet) {
setUser(hashSet);
}
public Set<user> getUser() {
return userliste;
}
public void setUser(Set<user> user) {
this.userliste = user;
}
public void setEventid(int eventid) {
this.eventid = eventid;
}
@ManyToOne //(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name="sportart")
public sportarten getsportart() {
return sportart;
}
public void setsportart(sportarten eventtyp) {
this.sportart = eventtyp;
}
public Set<user> getUserliste() {
return userliste;
}
public void setUserliste(Set<user> userliste) {
this.userliste = userliste;
}
public int getEventid() {
return eventid;
}
public Date getEventdate() {
return eventdate;
}
public void setEventdate(Date eventdate) {
this.eventdate = eventdate;
}
public String getEventplace() {
return eventplace;
}
public void setEventplace(String eventplace) {
this.eventplace = eventplace;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
}
Code:
package com.example;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "sportarten")
public class sportarten implements Serializable {
@Id
@Column(name = "sportart")
private String Sportart;
@Column(name = "maxspieler")
private int maxSpieler;
@ElementCollection(targetClass = events.class)
private Set<events> eventinkat;
public sportarten(String sportart, int maxSpieler, HashSet<events> hashSet) {
super();
Sportart = sportart;
this.maxSpieler = maxSpieler;
this.eventinkat = hashSet;
}
public String getSportart() {
return Sportart;
}
public void setSportart(String sportart) {
Sportart = sportart;
}
public int getMaxSpieler() {
return maxSpieler;
}
public void setMaxSpieler(int maxSpieler) {
this.maxSpieler = maxSpieler;
}
@OneToMany //(targetEntity = events.class, mappedBy = "sportart", fetch = FetchType.EAGER)
public Set<events> getEventinkat() {
return eventinkat;
}
public void setEventinkat(Set<events> eventListe) {
this.eventinkat = eventListe;
}
public sportarten() {
}
}
Where is the mistake?
The comments after ONETOMANY and MANYTOMANY makes no difference..
And i have now to create controllers MVC and work with them in a website.
Any tipps what would be the easiest way?Or do you know where to find a good example for it?