I am getting the following error while executing a EJB3 native query on MySQL 5. The query execute fine against the database.
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:231)
at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1677)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
... 161 more
I am not trying to map the result to any entity I just call
em.createNativeQuery(sql).getResultList();
SQL
Code:
Select d.filename, d.docid, d.status, d.visibilityId, d.type,d.createdBy, d.createdDate, d.fileTypeId, users, groups, di.index1,di.index2,di.index3 FROM Document d left join (SELECT docid, MAX( if (document_index.name='index1',document_index.value,'')) as index1, MAX( if (document_index.name='index2',document_index.value,'')) as index2, MAX( if (document_index.name='index3',document_index.value,'')) as index3 FROM document_index GROUP BY docid) as di on di.docid = d.docid left join ( SELECT docid, group_concat(user.name) as users FROM document_allocation da inner join user on user.userid = da.userid where da.current = 1 group by da.docid) as us on us.docid = d.docid left join ( SELECT docid, group_concat(g.name) as groups from document_allocation da inner join groups g on g.groupId = da.groupId group by da.docid) as groups on groups.docid = d.docid