/*
 *  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.place;

import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@Entity
@DiscriminatorValue(value = "2")
@NamedQueries({
                      @NamedQuery(name = State.FIND_BY_NAME, query = "SELECT p FROM State p WHERE p.name = :name"),
                      @NamedQuery(name = State.FIND_ALL, query = "SELECT p FROM State p")
              })
public class State extends Place
{

    public static final String FIND_ALL = "State.findAll";
    public static final String FIND_BY_NAME = "State.findByName";

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST})
    @JoinTable(name = "REGION_OF",
               joinColumns = @JoinColumn(name = "PLACE_ID"),
               inverseJoinColumns = @JoinColumn(name = "REGION_ID"))
    private Country country;

    public Country getCountry()
    {
        return country;
    }

    public void setCountry(Country country)
    {
        this.country = country;
    }

    @Override
    public String getLink()
    {
        return getName();
    }

    @Override
    public String toString()
    {
        Place[] places = {this, country};

        return toString(places);
    }
}
@@ -1089,657 +1089,175 @@
     
-@ManyToOne(fetch = FetchType.LAZY, cascade = %7BCascadeType.MERGE, CascadeType.PERSIST%7D)%0A    @JoinTable(name = %22REGION_OF%22,%0A               joinColumns = @JoinColumn(name = %22PLACE_ID%22),%0A               inverseJoinColumns = @JoinColumn(name = %22REGION_ID%22))%0A    private Country country;%0A%0A    public Country getCountry()%0A    %7B%0A        return country;%0A    %7D%0A%0A    public void setCountry(Country country)%0A    %7B%0A        this.country = country;%0A    %7D%0A%0A    @Override%0A    public String getLink()%0A    %7B%0A        return getName();%0A    %7D%0A%0A    @Override%0A    public String toString()%0A    %7B%0A        Place%5B%5D places = %7Bthis, country%7D;%0A%0A        return toString(places);%0A    
+public Country getCountry()%0A    %7B%0A        return getRegionByClass(Country.class);%0A    %7D%0A%0A    @Override%0A    public String getLink()%0A    %7B%0A        return getName();%0A    %7D%0A
 %7D%0A
-%7D

Update State.java