it is possible to map an interface method with type jsonb just as it is done in a class with @Entity.
In the example below it works fine, I have a column in postgres of type jsonb with the data [1,2,3,4].
Ex1:
@Entity
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Car {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Type(type = "jsonb")
private Set<Integer> blockedPlates;
}
But when creating an interface with a different projection than the domain class, I can't map the getBlockedPlates() method. Is there a way or not possible with interface?
Ex2
public interface ICarProjection {
public Integer getCodeCar();
public String getNameCar();
public Set<Integer> getBlockedPlates();
public Integer getYearCar();
}
@Repository
public interface CarRepository extends JpaRepository<Car, Integer> {
@Query(value = "select f.id as codeCar,"
+" f.name as nameCar,"
+" f.blocked_plates as blockedPlates,"
+" f.year as yearCar"
+" from car f", nativeQuery = true)
Optional<ICarProjection> find();
}
Error: org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: 1111; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111