title: Spring-Data-Jpa Repository - Underscore on Entity Column Name
body: <p>I am using spring-data-jpa on a spring webmvc project. I am facing an issue using <a href="http://docs.spring.io/spring-data/data-jpa/docs/current/reference/html/jpa.repositories.html#jpa.query-methods.query-creation" rel="noreferrer">query creation</a> on a Repository of one of my Entities. Below you can see my Entity, my Repository and the Exception.  </p>
  
  <p>My Entity:  </p>
  
  <pre><code>@Entity
  @Table(schema = "mainschema")
  @XmlRootElement
  public class Municipalperson implements Serializable {
  
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(nullable = false)
      private Integer id;
  
      @Basic(optional = false)
      @Column(name = "municipal_id", nullable = false)
      private Integer municipal_id;
  
      @Basic(optional = false)
      @Column(nullable = false, length = 60)
      private String firstname;
  
      public Municipalperson(Integer id, Integer municipal_id, String firstname) {
          this.id = id;
          this.municipal_id = municipal_id;
          this.firstname = firstname;
      }
  
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public Integer getMunicipal_id() {
          return municipal_id;
      }
  
      public void setMunicipal_id(Integer municipal_id) {
          this.municipal_id = municipal_id;
      }
  
      public String getFirstname() {
          return firstname;
      }
  
      public void setFirstname(String firstname) {
          this.firstname = firstname;
      }
  }
  </code></pre>
  
  <p>my Repository:  </p>
  
  <pre><code>@Repository
  public interface MunicipalpersonRepository extends JpaRepository&lt;Municipalperson, Integer&gt; {
  
      List&lt;Municipalperson&gt; findByMunicipal_idOrderByLastnameDesc(int municipal_id);
  }
  </code></pre>
  
  <p>and the exception,  </p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'municipalpersonRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property municipal found for type Municipalperson!  
  </code></pre>
  
  <p>I tried to set <code>municipal_id</code> as int, then as <code>Integer</code> and the same for the parameter <code>municipal_id</code> on my Repository, but none worked. Also, I renamed the Repository to <code>findByMunicipalidOrderByLastnameDesc</code> and <code>findByMunicipalIdOrderByLastnameDesc</code> but it didn't work either.  </p>
  
  <p>Finally I <strong>renamed</strong> the <code>municipal_id</code> to <code>municipalId</code> (underscore removed) and also renamed getters/setters and the Repository (<code>findByMunicipalIdOrderByLastnameDesc</code>) and <strong><em>the issue was resolved</em></strong>.  </p>
  
  <p>My question is why this is happening?</p>