I have repository method where i am trying to fetch specific column from table. when i call findAllNamesAndID method i get Object array in return where i am expecting List of Customwidgets.
I am not sure whats wrong with below code.
I can use use constructor of Customwidgets in query annotation but i want to avoid that. Is there any workaround.
I have below domain class :-
public class Customwidgets implements Serializable {
@Id
private UUID id;
@NotNull
@Column(name = "name", nullable = false)
private String name;
---
---
}
My Repository class :-
@Repository
public interface CustomwidgetsRepository extends JpaRepository<Customwidgets, UUID>, JpaSpecificationExecutor<Customwidgets> {
@Query("select o.id, o.name from Customwidgets o")
List<Customwidgets> findAllNamesAndID();
}