I have a simple POJO:
I'm trying to map title column to title field:
@SqlResultSetMapping(
name = "ownerSaleMapping",
classes = {
@ConstructorResult(
targetClass = OwnerSale.class,
columns = {
@ColumnResult(name = "title", type = String.class)
}
)
}
)
@NamedNativeQuery(name = "ownerSaleReport", query = "SELECT title FROM content where id=:contentId", resultSetMapping = "ownerSaleMapping")
public class OwnerSale {
public OwnerSale() {
}
private String title;
public OwnerSale(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
My repository interface:
public interface OwnerSaleRepository extends JpaRepository<OwnerSale, Long> {
List<OwnerSale> ownerSaleReport(@Param("contentId") Long ownerId);
}
But when i'm using that:
List<OwnerSale> sales = ownerSaleRepository.ownerSaleReport(6);
I got this error:
IllegalArgumentException: Not an managed type: class domain.owner.OwnerSale
But i need to OwnerSale be a POJO not an Entity.
what is the solution?
JpaRepository<OwnerSale, Long>@SqlResultSetMappingand@NamedNativeQuerybut can't add@Entityand@Id