Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

In this short article, we’ll shed light on how to fix the Spring Data JPA exception PropertyReferenceException: No property found for type.

First, we’ll explain the leading causes behind this exception. Then, we’ll illustrate how to reproduce it using practical examples, and finally, how to fix it.

2. The Cause

Before diving deep into the details, let’s try to understand what the exception means.

The stack trace “No property found for type” simply tells us that a specified property is not found. Spring Data throws this exception when it fails to access a property that doesn’t exist or hasn’t been defined.

Typically, Spring Data automatically generates SQL queries from the names of the derived query methods. So, one of the most common causes behind the exception is defining a query method with invalid properties.

Another reason would be misspelling a property name when accessing the property.

3. Reproducing the Exception

Now that we know what the exception means, let’s see how to reproduce it in practice.

For instance, let’s consider the Person entity class:

@Entity
public class Person {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;
    private String firstName;
    private String lastName;

    // standard getters and setters
}

Now, let’s create a Spring Data JPA repository for our Person class:

@Repository
public interface PersonRepository extends JpaRepository<Person, Integer> {
}

Next, we’ll add a query method to get a person by first name. However, let’s pretend to misspell the firstName property.

For example, let’s write firsttName instead:

Person findByFirsttName(String lastName);

Now, if we start our Spring Boot application, we’ll get:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personRepository' defined in com.baeldung.nopropertyfound.repository.PersonRepository ...
...
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract com.baeldung.nopropertyfound.model.Person com.baeldung.nopropertyfound.repository.PersonRepository.findByFirsttName(java.lang.String)! 
No property 'firsttName' found for type 'Person'; Did you mean 'firstName'
...
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 'firsttName' found for type 'Person'; Did you mean 'firstName'
...

As we can see in the logs, Spring Boot fails with PropertyReferenceException: No property ‘firsttName’ found for type ‘Person’.

Spring Data automatically checks if the generated SQL queries are valid at startup.

Since we’re using a property that doesn’t exist (firsttName), Spring Data fails to generate the SQL query, hence the exception.

4. The Solution

There’s only one way to fix the exception: to use the exact property names when defining query methods.

So, to fix the issue, we need to rename findByFirsttName() to findByFirstName().

Person findByFirstName(String firstName);

Now, let’s confirm using a test case that everything works as expected:

@Test
void givenQueryMethod_whenUsingValidProperty_thenCorrect() {

    Person person = personRepository.findByFirstName("Azhrioun");

    assertNotNull(person);
    assertEquals("Abderrahim", person.getLastName());
}

As shown above, the query method findByFirstName() doesn’t fail and does the job of returning a person by first name.

In nutshell, here are some key points to keep in mind to avoid PropertyReferenceException:

  • Use the exact property names when defining query methods.
  • Avoid using abbreviations or misspelled names.
  • Double-check the entity class to make sure that the property we want to reference exists and is spelled correctly.
  • Use a code editor with autocomplete features to reduce the risk of misspelling property names.
  • Write unit or integration tests for query methods to ensure that they’re returning the expected results.

5. Conclusion

To sum it up, we discussed in detail what causes Spring Data to throw PropertyReferenceException: No property found for type.

Along the way, we used practical examples to illustrate how to produce the exception and how to fix it.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW