micronaut-projects / micronaut-data

Ahead of Time Data Repositories
Apache License 2.0
466 stars 197 forks source link

Entity with public fields not supported #2615

Open radovanradic opened 11 months ago

radovanradic commented 11 months ago

Expected Behavior

Having an entity

@MappedEntity
public class ExampleDomain {

    @Id
    public Long id;

    public String name;
}

and repository

@JdbcRepository(dialect = Dialect.H2)
public interface ExampleDomainRepository extends CrudRepository<ExampleDomain, Long> {

    ExampleDomain findByName(String name);
}

Repository should support findById and custom findByName method.

Actual Behaviour

The compiler error is thrown:

Unable to implement Repository method: ExampleDomainRepository.update(Object entity). No identity is present

Also won't be able to implement findByName complaining

Unable to implement Repository method: ExampleDomainRepository.findByName(String name). Cannot query entity [ExampleDomain] on non-existent property: Name

Steps To Reproduce

Just try to create repository for the entity above.

Environment Information

Any

Example Application

No response

Version

3.x, 4.x

graemerocher commented 11 months ago

not sure if this is a bug, the user would need to specify the access kind. See https://docs.micronaut.io/latest/api/io/micronaut/core/annotation/Introspected.html#accessKind()

radovanradic commented 11 months ago

I tried this

@MappedEntity
@Introspected(accessKind = Introspected.AccessKind.FIELD)
public class ExampleDomain {

    @Id
    public Long id;

    public String name;
}

and getting the same compilation errors.