Article has many HeaderKey which has many HeaderValue ORM
===

The database looks as:

    mysql> 
    mysql> 
    mysql> SHOW TABLES;
    +------------------+
    | Tables_in_usenet |
    +------------------+
    | ARTICLE          |
    | HEADERFIELD      |
    | NEWSGROUP        |
    +------------------+
    3 rows in set (0.00 sec)
    
    mysql> 
    mysql> DESCRIBE ARTICLE;
    +---------+--------------+------+-----+---------+----------------+
    | Field   | Type         | Null | Key | Default | Extra          |
    +---------+--------------+------+-----+---------+----------------+
    | ID      | bigint(20)   | NO   | PRI | NULL    | auto_increment |
    | SUBJECT | varchar(255) | YES  |     | NULL    |                |
    +---------+--------------+------+-----+---------+----------------+
    2 rows in set (0.00 sec)
    
    mysql> 
    mysql> DESCRIBE HEADERFIELD;
    +-------------+--------------+------+-----+---------+----------------+
    | Field       | Type         | Null | Key | Default | Extra          |
    +-------------+--------------+------+-----+---------+----------------+
    | ID          | bigint(20)   | NO   | PRI | NULL    | auto_increment |
    | HEADERNAME  | varchar(255) | YES  |     | NULL    |                |
    | HEADERVALUE | varchar(255) | YES  |     | NULL    |                |
    | ARTICLE_ID  | bigint(20)   | YES  | MUL | NULL    |                |
    +-------------+--------------+------+-----+---------+----------------+
    4 rows in set (0.00 sec)
    
    mysql> 


where HEADERFIELD(s) are `javax.mail.Header` key/value pairs.  There's a redundant column, ARTICLE.SUBJECT, in that "subject" is just another header, so I can remove that column.

However, the headers are massively redundant, the same few keys over and over.  So, that needs to be split into a one-to-many for, say, HEADER_KEYS AND HEADER_VALUES?

To achieve, this, refactor HeaderField:


    package net.bounceme.dur.usenet.model;
    
    import java.io.Serializable;
    import java.util.AbstractMap.SimpleEntry;
    import java.util.logging.Logger;
    import javax.persistence.*;
    
    @Entity
    public class HeaderField implements Serializable {
    
        private static final long serialVersionUID = 1L;
        private static final Logger LOG = Logger.getLogger(HeaderField.class.getName());
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;
        @ManyToOne(cascade = CascadeType.PERSIST)
        private Article article = new Article();
        @Column
        private String headerName;
        @Column
        private String headerValue;
    
        public HeaderField() {
        }
    
        public HeaderField(SimpleEntry nameValue) {
            headerName = nameValue.getKey().toString();
            headerValue = nameValue.getValue().toString();
        }
    
        public Long getId() {
            return id;
        }
    
        public void setId(Long id) {
            this.id = id;
        }
    
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (id != null ? id.hashCode() : 0);
            return hash;
        }
    
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof HeaderField)) {
                return false;
            }
            HeaderField other = (HeaderField) object;
            if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                return false;
            }
            return true;
        }
    
        @Override
        public String toString() {
            return "\n\nheaderName\t" + headerName + "\nheaderValue\t" + headerValue;
        }
    
        public String getHeaderName() {
            return headerName;
        }
    
        public void setHeaderName(String headerName) {
            this.headerName = headerName;
        }
    
        public String getHeaderValue() {
            return headerValue;
        }
    
        public void setHeaderValue(String headerValue) {
            this.headerValue = headerValue;
        }
    }



and just add in a one-to-many to a HeaderKey entity?


