/*
 *  The MIT License (MIT)
 *
 *  View the full license at:
 *  https://github.com/hendrixjoseph/FamilyTree/blob/master/LICENSE.md
 *
 *  Copyright (c) 2015 Joseph Hendrix
 *
 *  Hosted on GitHub at https://github.com/hendrixjoseph/FamilyTree
 *
 */

package edu.wright.hendrix11.familyTree.entity.event;

import edu.wright.hendrix11.familyTree.entity.Person;
import edu.wright.hendrix11.familyTree.entity.compositeKey.MarriagePK;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.TypedQuery;

/**
 * @author Joe Hendrix <hendrix.11@wright.edu>
 */
@Entity
@IdClass(MarriagePK.class)
@NamedQuery(name = Marriage.FIND_ALL, query = "SELECT m FROM Marriage m")
public class Marriage extends Event
{
    /**
     * Specifies the {@link String} that represents the {@link NamedQuery} to create a {@link TypedQuery} to get all
     * marriage records.
     */
    public static final String FIND_ALL = "Marriage.findAll";

    @Id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "HUSBAND")
    private Person husband;
    @Id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "WIFE")
    private Person wife;

    /**
     * @return
     */
    public Person getHusband()
    {
        return husband;
    }

    /**
     * @param husband
     */
    public void setHusband(Person husband)
    {
        this.husband = husband;
    }

    /**
     * @return
     */
    public Person getWife()
    {
        return wife;
    }

    /**
     * @param wife
     */
    public void setWife(Person wife)
    {
        this.wife = wife;
    }

    /**
     * @return
     */
    public boolean hasHusband()
    {
        return hasSpouse(husband);
    }

    /**
     * @return
     */
    public boolean hasWife()
    {
        return hasSpouse(wife);
    }

    private boolean hasSpouse(Person spouse)
    {
        return spouse != null;
    }

}
@@ -1059,16 +1059,173 @@
 ecords.%0A
+     * For example: %0A     * %3Cblockquote%3E%3Cpre%3E%7B@code TypedQuery%3CMarriage%3E query = em.createNamedQuery(Marriage.FIND_ALL, Marriage.class);%7D%3C/pre%3E%3C/blockquote%3E%0A
      */%0A
@@ -1519,121 +1519,294 @@
   * 
-@return%0A     */%0A    public Person getHusband()%0A    %7B%0A        return husband;%0A    %7D%0A%0A    /**%0A     * @param husband
+Returns the male person of the marriage.%0A     * %0A     * @return the male person of the marriage%0A     */%0A    public Person getHusband()%0A    %7B%0A        return husband;%0A    %7D%0A%0A    /**%0A     * Sets the male person of the marriage.%0A     * %0A     * @param husband the male person of the marriage
 %0A   
@@ -1917,111 +1917,106 @@
   * 
-@r
+R
 eturn
-%0A     */%0A    public Person getWife()
+s the female person of the marriage.
 %0A    
-%7B%0A  
+ * %0A
      
- 
+* @
 return 
-wife;%0A    %7D%0A%0A    /**%0A     * @param wif
+the female person of the marriag
 e%0A  
@@ -2036,32 +2036,23 @@
 lic 
-void setWife(
 Person 
-w
+getW
 ife
+(
 )%0A  
@@ -2067,19 +2067,14 @@
     
-this.wife =
+return
  wif
@@ -2102,237 +2102,139 @@
   * 
-@return%0A     */%0A    public boolean hasHusband()
+Sets the female person of the marriage.
 %0A    
-%7B%0A  
+ * %0A
      
- return hasSpouse(husband);%0A    %7D%0A%0A    /**%0A     * @return%0A     */%0A    public boolean hasWife()%0A    %7B%0A        return hasSpouse(wife);%0A    %7D%0A%0A    private boolean hasSpous
+* @param wife the female person of the marriage%0A     */%0A    public void setWif
 e(Pe
@@ -2238,21 +2238,19 @@
 (Person 
-spous
+wif
 e)%0A    %7B
@@ -2262,35 +2262,30 @@
     
-return spous
+this.wif
 e 
-!
 = 
-null
+wife
 ;%0A    %7D%0A
 %0A%7D
@@ -2286,6 +2286,6 @@
   %7D%0A
-%0A
 %7D
+%0A

Update Marriage.java