-->
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.  [ 1 post ] 
Author Message
 Post subject: can't delete OneToMany child
PostPosted: Mon Mar 24, 2014 2:20 pm 
Newbie

Joined: Mon Mar 24, 2014 2:13 pm
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.