Skip to content

Invalid projection definition #1335

@gastonlagaf

Description

@gastonlagaf

Got this on Version: 3.4.5

Steps For Reproduction:

Got Entity Class:

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table("users_by_email")
public class CassandraUserByEmail extends CassandraEntity<Long> implements User {

    private String email;

    private String phoneNumber;

    private LocationDetails locationDetails;

    @Id
    public String getEmail() {
        return email;
    }
}

And repository interface to it:

public interface UserByEmailCassandraRepository extends BaseCassandraRepository<CassandraUserByEmail, Long> {

    Optional<User> findByEmail(String value);

}

Repository interface parent, supplied with additional interface, required for rest of the repositories

public interface BaseCassandraRepository<T extends Entity<ID>, ID extends Serializable> extends CassandraRepository<T, ID>, Repository<T, ID, CriteriaContainer> {
}

Expected Behaviour:
Mind that CassandraUserByEmail implements User interface. I expect that findByEmail method will return interface implementation, specified in generic.

Actual Behaviour:
Error with message

Failed to instantiate [com.gastonlagaf.springcassandra.entity.User]: Specified class is an interface

Investigations:
In CassandraAbstractQuery class there is a snippet (

private Class<?> resolveResultType(ResultProcessor resultProcessor) {
CassandraReturnedType returnedType = new CassandraReturnedType(resultProcessor.getReturnedType(),
getOperations().getConverter().getCustomConversions());
return returnedType.isProjecting() ? returnedType.getDomainType() : returnedType.getReturnedType();
}
)

Maybe there should be considered a case when returned instance class is interface of domain type

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions