For example, I have an entity with the following attribute:
@Entity
public class MyObj {
public String nameOrId;
}
I then proceed to create the repository
public interface MyObjRepository extends JpaRepository<MyObj, String> {
MyObj findByNameOrId(String nameOrId);
}
This fails, because it seems that Spring tokenizes the method name as findBy Name Or Id, instead of findBy nameOrId.
The resulting error is "name" property not found (or similar).
Is there a way to escape the special words ("Or", "And", etc) in the method syntax? Renaming the column to not include those words is not an option.
@Queryannotation on top of your method to give the JpaRepository the query you want to execute