cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

ReactiveNeo4jRepository: No property found for type

chris3
Graph Buddy

I am thinking about giving SDN a go again, trying out Interface-based Projections:

interface UserSDNRepository : ReactiveNeo4jRepository<UserSDN, Long> {
  fun findAllUsernames(): Flux<UsernameOnly>
}

interface UsernameOnly {
	val username: String?
}

and also tried a Java interface like

public interface UsernameOnly{
	String getUsername();
}

but as soon as Spring Boot starts up I get:

...
Caused by: org.springframework.data.mapping.PropertyReferenceException:
No property 'findAllUsernames' found for type 'UserSDN'!
...

I have tried different names for the findAll function.
BTW I also have a fun findByUsername(username: String): Mono<SimpleUser> where SimpleUser is a class based projection and that works fine.

What am I missing here? I think according to the docs at Spring Data Neo4j that should work. Is it not possible with Reactive repositories? Or is it a Kotlin issue?

Cheers, Chris

2 REPLIES 2

This is not a problem with projections but the query method you are defining.
The fun findByUsername(username: String): Mono<SimpleUser> works because you are looking for the username field in the entity UserSDN.
The other query method defines a findAll_Usernames_. This will make SDN look into UserSDN for the property usernames (plural). The error message gives the hint that it cannot find this particular property.
Back to your use-case:
If you do not want to use the property, you could write fun findAllProjectedBy(): Flux<UsernameOnly>.
What you could also do, is to write a generic projection method like this:

fun <T> findAllProjectedBy(projectionClass: Class<T>): List<T>

This would allow you to use different projection if needed.

Thanks for the reply, Gerrit!