title: want to autowire DAO class in my entity class
body: <p>i have a method which i need to call in my entity class company.java.
  but when i run my application it throws null pointer exception didn't fount that DAO object in entity class..</p>
  
  <p>How can i get that object in entity class please help</p>
  
  <p>This is my entity class..</p>
  
  <pre><code>package com.salebuild.model;
  
  /**
   * Define a company.
   *
   * @author mseritan
   */
  @Entity
  @Table(name = "company", uniqueConstraints = {@UniqueConstraint(columnNames = "name")})
  @XmlRootElement
  @XmlSeeAlso(value = ArrayList.class)
  public class Company implements PublishableIF, Serializable, PersistableIF, HistoryIF, AddressableIF {
       private static final Logger log = LoggerFactory.getLogger( Company.class );
       @Autowired
          private CompanyDAO companyDAO;
  
      // CONSTANTS -----------------------------------------------------------------------------------
  
      private static final long serialVersionUID = 1L;
  
      // ATTRIBUTES ----------------------------------------------------------------------------------
  
      private Long id;
      @NotBlank
      private String name;
      private String formerName;
      private CorporateTitle topLevelExec;
      private List&lt;CompanySite&gt; sites;
      private List&lt;CompanyAlias&gt; aliases;
      @NotNull
      private Industry industry;
      private Company parentCompany;
      private String emailTopology;
      @NotNull
      private Double revenue;
  
      @NotNull
      private Long numberEmployees;
      private CustomerType.Type customerType;
      private Boolean recruiter = false;
      private int publishState;
      private CompanyStatus status;
      private Boolean excludeCompany = false;
      private CompanyType companyType;
      private String salesifyCompanyId;
      private CompanySiteType companySiteType;
      private String websiteUrl;
      private String sourceVendor;
      private String notes;
      private List&lt;CompanySpecializedRanking&gt; specializedList = new ArrayList&lt;CompanySpecializedRanking&gt;();
      @NotNull
      private NAICSCode naicsCode;
      @NotNull
      private SICCode sicCode;
      private Long version;
      private List&lt;Technology&gt; technologies = new ArrayList&lt;Technology&gt;();
      private List&lt;CompanyContact&gt; contacts;
      private String phoneNumber;
      private String faxNumber;
      private String email;
  
      private User userCreated;
      private Date dateCreated;
  
      private User userLastModified;
      private Date dateLastModified;
  
      private User userLastResearcher;
      private Date dateLastResearcher;
      @NotBlank
      private String street1;
      private String street2;
      private String street3;
      private String city;
      private String zipCode;
      private State state;
      private Country country;
      private String specRankingListName;
      private Integer specRankingRank;
      private Integer specRankingYear;
      private String modifiedCompanyName;
  
      private String formattedRevenue;
      private String formattedEmployeeSize;
      private List&lt;JobPostingRaw&gt; unconfirmedTechnologies;
      // ACESSORS ------------------------------------------------------------------------------------
     //getter setter for other fields //
          this.specRankingYear = specRankingYear;
      }
  
  
      /**
       * @param modifiedCompanyName  
       *
       */
      @Column(name="modifiedCompanyName")
      public String getModifiedCompanyName() {
          return modifiedCompanyName;
      }
  
      public void setModifiedCompanyName(String modifiedCompanyName) {
          if(modifiedCompanyName==null)
              this.modifiedCompanyName=modifiedCompanyName;
          else{
           this.modifiedCompanyName =companyDAO.updateCompanyName(modifiedCompanyName);
          }
      }
  
      @Transient
      public List&lt;JobPostingRaw&gt; getUnconfirmedTechnologies() {
          return unconfirmedTechnologies;
      }
  
      public void setUnconfirmedTechnologies(
              List&lt;JobPostingRaw&gt; unconfirmedTechnologies) {
          this.unconfirmedTechnologies = unconfirmedTechnologies;
      }
  
  
  
  }
  </code></pre>
  
  <p>my DAO class is like that --</p>
  
  <pre><code>package com.salebuild.dao;
  
  import com.salebuild.model.Company;
  import com.salebuild.model.search.EntitySearchCriteria;
  import com.salebuild.model.search.SortedResultsPage;
  
  import java.util.Collection;
  import java.util.List;
  import java.util.Set;
  
  public interface CompanyDAO extends CrudDAO&lt;Company&gt; {
      Company findByNameOrAlias(String name);
  
      List&lt;Company&gt; findBySearchTerm(String searchTerm, Integer start, Integer count);
  
     // SortedResultsPage&lt;Company&gt; findPaged(EntitySearchCriteria criteria);
  
      List&lt;Long&gt; findIds(EntitySearchCriteria criteria);
  
      List&lt;Company&gt; find(Collection&lt;Long&gt; ids);
  
      /**
       * For just finding the company name and not looking for alias names.
       *
       * @param name
       * @return
       */
      public Company findByName( String name );
      public Company findByModifiedName(String name,Company... c);
  
      public int companyCountSinceLastLogin(Long id);
  
      Set&lt;Long&gt; findDistinctIds(EntitySearchCriteria criteria);
  
      public Integer getCompanyCountByRegion(Long regionId,List techCatIds);
  
      List&lt;Company&gt; findAllCompanies(Company instance);
  
      public List&lt;Company&gt; findAllModifiedCompanies(Company instance);
  
      public String updateCompanyName(String name);
  }
  </code></pre>