我有以下 JPA SqlResultSetMapping:
@SqlResultSetMappings({
@SqlResultSetMapping(name="GroupParticipantDTO",
columns={
@ColumnResult(name="gpId"),
@ColumnResult(name="gpRole"),
// @ColumnResult(name="gpRemarks")
}
)
这是这样使用的:
StringBuilder sbQuery = new StringBuilder("Select ");
sbQuery.append(" gpId, ");
sbQuery.append(" gpRole, ");
// sbQuery.append(" gpRemarks ");
sbQuery.append(" FROM v_group_participants_with_details ");
Query query = em.createNativeQuery(sbQuery.toString(), "GroupParticipantDTO");
视图是这样的:
DROP VIEW IF EXISTS `v_group_participants_with_details`;
CREATE VIEW `v_group_participants_with_details`
AS
SELECT
gp.id AS gpId,
gp.role AS gpRole,
gp.remarks AS gpRemarks
FROM GroupParticipation gp
;
GroupParticipation 表的备注列定义为 LONGTEXT(我使用的是 Mysql 5.x)
现在解决问题:当从查询中注释掉备注字段时,一切正常,但是如果我尝试在查询中包含备注字段,则会收到以下错误:
javax.persistence.PersistenceException: org.hibernate.MappingException:
No Dialect mapping for JDBC type: -1
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException
(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:76)
是什么赋予了?如何从本机查询中获取 LONGTEXT 列?