I am experiencing the following problem:
I have 3 Pojo's
Artist
Album
Track
With the Artist having a OneToMany relationship with Album, and Album having a OneToMany relationship with Track.
Code:
@Entity
public class Artist {
@Id
@GeneratedValue
@Column(name = "artist_id")
private long artist_id;
@Column(name = "artist_name", nullable = false, length = 32)
private String artist_name;
@Column(name = "artist_bio", nullable = false, length = 255)
private String artist_bio;
@Lob
@Basic(fetch = FetchType.EAGER)
@Column(name = "artist_avatar")
private byte[] artist_avatar;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "artist", orphanRemoval = true)
private List<Album> albumList;
Code:
@Entity
public class Album {
@Id
@GeneratedValue
@Column(name = "album_id")
private long album_id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "artist_id", nullable = false)
private Artist artist;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "album", orphanRemoval = true)
private List<Track> trackList;
@Column(name = "album_name", nullable = false, length = 32)
private String album_name;
@Column(name = "album_description", nullable = false, length = 255)
private String album_description;
@Lob
@Basic(fetch = FetchType.EAGER)
@Column(name = "album_avatar")
private byte[] album_avatar;
Code:
@Entity
public class Track {
@Id
@GeneratedValue
@Column(name = "track_id")
private long track_id;
@Column(name = "track_no", nullable = false, length = 2)
private String track_no;
@Column(name = "track_name", nullable = false, length = 32)
private String track_name;
@Column(name = "track_length", nullable = false, length = 32)
private String track_length;
@Column(name = "track_file", nullable = false, length = 128)
private String track_file;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "album_id", nullable = false)
private Album album;
Code:
public void deleteTrack(Long track_id) {
trackRepository.delete(track_id);
}
When I call the trackService.deleteTrack(track_id); the track in my MySQL database isn't deleted. Hibernate just gives me a lot of select statements as output.
Any help is appreciated and if you need more information from me feel free to ask.