Skip to content

Simple Type projections: Couldn't find PersistentEntity #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zbornstein opened this issue Mar 26, 2019 · 1 comment
Closed

Simple Type projections: Couldn't find PersistentEntity #83

zbornstein opened this issue Mar 26, 2019 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@zbornstein
Copy link

zbornstein commented Mar 26, 2019

I saw a similar post on simple type projections for repositories, but I'm not using repositories.

@Bean
ConnectionFactory connectionFactory() {
    PostgresqlConnectionConfiguration config = PostgresqlConnectionConfiguration.builder()
            .host(host)
            .port(5432)
            .database(databaseName)
            .username(username)
            .password(password)
            .build();
    return new PostgresqlConnectionFactory(config);
}

public DatabaseClient getClient() {
    return DatabaseClient.create(connectionFactory());
}

public Mono<String> getAttemptCount() {
        return postgresDatabaseConfig.getClient()
                .execute()
                .sql("SELECT recipient FROM entity WHERE uuid = CAST($1 AS UUID)")
                .bind("$1", "5e89de44-a4c4-40eb-4321-25f4b91654cf")
                .as(String.class)
                .fetch()
                .first();
}

I get `"error": "Internal Server Error",
    "message": "Couldn't find PersistentEntity for type class java.lang.String!"`

I have been able to get similar code working with 
<dependency>
    <groupId>io.r2dbc</groupId>
    <artifactId>r2dbc-client</artifactId>
    <version>1.0.0.M7</version>
  </dependency>

public Mono<String> getAttemptCount() {
        return postgresConfig.getR2DBCClient()
                .withHandle(handle -> 
                    handle.select("SELECT recipient FROM entity WHERE uuid = CAST($1 AS UUID)")
                     .bind("$1", "5e89de44-a4c4-40eb-4321-25f4b91654cf")
                    .mapResult(result -> result.map((row, rowData) -> row.get("recipient", Integer.class))))
                    .next();
    }

but I don't see any reason why I can't use spring-data-r2dbc itself.
@zbornstein zbornstein changed the title Simple Type projections Simple Type projections:: 'Couldn't find PersistentEntity for type' Mar 26, 2019
@mp911de
Copy link
Member

mp911de commented Mar 26, 2019

That's a duplicate of #41. The issue is fixed with the current snapshot build. Care to give the latest snapshots a spin?

@mp911de mp911de closed this as completed Mar 26, 2019
@mp911de mp911de added the status: duplicate A duplicate of another issue label Mar 26, 2019
@mp911de mp911de changed the title Simple Type projections:: 'Couldn't find PersistentEntity for type' Simple Type projections: Couldn't find PersistentEntity Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants