title: Hibernate can insert but does not delete entry
body: <p>I'm having issues trying to delete an entry in my database table.
  The structure of the database is as follows:</p>
  
  <pre><code>User ---&lt; UserET &gt;--- ExitTicket
  </code></pre>
  
  <h3>ExitTicket.java</h3>
  
  <pre><code>@Entity
  @Table(name = "exit_ticket")
  public class ExitTicketEntry implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
      private long id;
      private String title;
      private String dateET;
      private Set&lt;UserET&gt; userETs= new HashSet&lt;UserET&gt;();
  
      public ExitTicketEntry() {}
  
      public ExitTicketEntry(String title,String dateET) {
          this.title = title;
          this.dateET = dateET;
      }     
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY )
      @Column(name = "ticket_id")
      public long getId() {
          return id;
      }
      public void setId(long id) {
          this.id = id;
      }
  
      @OneToMany(mappedBy = "exitTicketEntry", orphanRemoval=true)
      public Set&lt;UserET&gt; getUserETs() {
          return userETs;
      }
  
      public void setUserETs(Set&lt;UserET&gt; userETs) {
          this.userETs = userETs;
      }
  
      public void addUserETs(UserET userETs) {
          this.userETs.add(userETs);
      }
  
      //getters and setters
  }
  </code></pre>
  
  <h3>UserET.java</h3>
  
  <pre><code>@Entity
  @Table(name="userET")
  public class UserET implements Serializable {
  
      //private static final long serialVersionUID = 1L;
  
      private long answerId;
      private User user;
      private ExitTicketEntry exitTicketEntry;
      private String answer;
      private Date dateAnswer;
  
      @Id
      @GeneratedValue
      @Column(name="answerId")
      public long getAnswerId() {
          return answerId;
      }
      public void setAnswerId(long answerId) {
          this.answerId = answerId;
      }
  
      @ManyToOne(cascade = CascadeType.ALL )
      @JoinColumn(name = "user_id")  
      public User getUser() {
          return user;
      }
      public void setUser(User user) {
          this.user = user;
      }
  
      @ManyToOne(cascade = CascadeType.ALL)
      @JoinColumn(name = "ticket_id")  
      public ExitTicketEntry getExitTicketEntry() {
          return exitTicketEntry;
      }
      public void setExitTicketEntry(ExitTicketEntry exitTicketEntry) {
          this.exitTicketEntry = exitTicketEntry;
      }
  
      @Column(name = "answer")
      public String getAnswer(){
          return answer;
      }
      public void setAnswer(String answer) {
          this.answer = answer;
      }
  
      @Column(name = "dateAnswer")
      @Temporal(TemporalType.DATE)
      public Date getDateAnswer() {
          return dateAnswer;
      }
      public void setDateAnswer(Date dateAnswer) {
          this.dateAnswer = dateAnswer;
      }
  </code></pre>
  
  <h3>User.java</h3>
  
  <pre><code>@Entity
  @Table(name="USER")
  public class User implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      private long id;
      private String user_name, user_password, user_type,user_realname;
  
      private Set&lt;UserET&gt; userETs= new HashSet&lt;UserET&gt;();
  
      public User() {
      }
  
      public User(String user_name,String user_password,String user_type,String user_realname) {
          this.user_name = user_name;
          this.user_password = user_password;
          this.user_type = user_type;
          this.user_realname=user_realname;
      }
  
      public void addExitTicketEntry(UserET group) {
          this.userETs.add(group);
      }
  
      @Id
      @GeneratedValue
      @Column(name="user_id")
      public long getId() {
          return id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      @OneToMany(mappedBy = "user", orphanRemoval=true)
      public Set&lt;UserET&gt; getUserETs() {
          return userETs;
      }
  
      public void setUserETs(Set&lt;UserET&gt; userETs) {
          this.userETs = userETs;
      }
  
      public void addUserETs(UserET userETs) {
          this.userETs.add(userETs);
      } ... + getters and setters
  </code></pre>
  
  <p>I am able to insert a new <code>Entry</code> of <code>ExitTicket</code> correctly (using ExitTicketService.java), with this function:</p>
  
  <pre><code>public void addEntryET(ExitTicketEntry exitTicketEntry) {
      log.info("adding entry in database");
      try {
          hibernateTemplate.save(exitTicketEntry);
      }
      catch(Exception e) {
          log.info("error adding an entry in the database-&gt;"+e.toString());
      }
  }
  </code></pre>
  
  <p>However when I try to delete an entry from the database table, the hibernate delete only does 'select' commands and never gets to do a 'delete'</p>
  
  <pre><code>2018-11-05 09:28:27 INFO  AuthService:72 - entro 1 ------
  Hibernate: select exitticket0_.ticket_id as ticket_i1_0_0_, exitticket0_.dateET as dateET2_0_0_, exitticket0_.title as title3_0_0_ from exit_ticket exitticket0_ where exitticket0_.ticket_id=?
  Mon Nov 05 09:28:27 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
  2018-11-05 09:28:27 TRACE BasicBinder:65 - binding parameter [1] as [BIGINT] - [9]
  2018-11-05 09:28:27 TRACE BasicExtractor:61 - extracted value ([dateET2_0_0_] : [VARCHAR]) - [2011-05-20]
  2018-11-05 09:28:27 TRACE BasicExtractor:61 - extracted value ([title3_0_0_] : [VARCHAR]) - [test1]
  2018-11-05 09:28:27 TRACE CollectionType:790 - Created collection wrapper: [com.jcg.spring.hibernate.pojo.ExitTicketEntry.userETs#9]
  Hibernate: select userets0_.ticket_id as ticket_i4_2_0_, userets0_.answerId as answerId1_2_0_, userets0_.answerId as answerId1_2_1_, userets0_.answer as answer2_2_1_, userets0_.dateAnswer as dateAnsw3_2_1_, userets0_.ticket_id as ticket_i4_2_1_, userets0_.user_id as user_id5_2_1_, user1_.user_id as user_id1_1_2_, user1_.user_name as user_nam2_1_2_, user1_.user_password as user_pas3_1_2_, user1_.user_realname as user_rea4_1_2_, user1_.user_type as user_typ5_1_2_ from userET userets0_ left outer join USER user1_ on userets0_.user_id=user1_.user_id where userets0_.ticket_id=?
  2018-11-05 09:28:27 TRACE BasicBinder:65 - binding parameter [1] as [BIGINT] - [9]
  2018-11-05 09:28:27 INFO  AuthService:99 - deleted entry with ID#=9
  </code></pre>
  
  <p>My delete function in my service class:</p>
  
  <pre><code>public void deleteById(Class&lt;?&gt; type, long id) {
      log.info("entro 1 ------");
      ExitTicketEntry e=(ExitTicketEntry) hibernateTemplate.load(type,id);
      hibernateTemplate.delete(e);
  }
  </code></pre>
  
  <p>I've been reading plenty of forums, but still have the same issue, I can't delete any entries. Am I missing something?</p>