Does JPA with Spring-Data have a problem with attributes with underscores "_" in their names? This is my interface that extends JpaRepository
:
public interface I_My_Class extends JpaRepository<MyClass, Long> {
public MyClass findByA_my_table_id (Long headerId);
}
This line: findByA_my_table_id (Long headerId);
gives this error:
Invalid derived query! No property "a" found for type MyClass !
If I name the method public MyClass findBya_my_table_id (Long headerId);
it gives me the same error. If I name the attribute amytableid
without the underscores I don't get the error but if I do that it's not easy to read later on. This is the class where I have the table attribute:
@Entity
@Table(name="MyTable")
public class MyClass implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column (name="MY_TABLE_ID", nullable=false)
private Long a_my_table_id; // <-- this is the attribute that I try to put in the named query
}