Unfortunately, I need to use native SQL queries for part of my project to return tuples from unmarked tables.
I have a bunch of queries that should return the same number of values ββfor each row, and then move on to the processing method to turn them into objects.
eg:
List<Object[]> list = ...; List<MyBean> beans = ...; SQLQuery qry1 = session.createSQLQuery(...); SQLQuery qry2 = session.createSQLQuery(...); SQLQuery qry3 = session.createSQLQuery(...); list.addAll(qry1.list()); list.addAll(qry2.list()); list.addAll(qry3.list()); for(Object[] tuple : list) { MyBean bean = new MyBean(); bean.setSomething0(tuple[0]); bean.setSomething1(tuple[1]); bean.setSomething2(tuple[2]); bean.setSomething3(tuple[3]); beans.add(bean); }
now my problem is that qry3 does not have a relevance column to populate the value in the second index of the tuple, but populates the third index. I need to modify the request so that it somehow fills in a null or "" tuple.
I tried "select a, b, null, d" and "select a, b, '', d" , but both of them throw an exception:
org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111 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:370) 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:1796) at org.hibernate.loader.Loader.doQuery(Loader.java:674) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2213) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) at org.hibernate.loader.Loader.list(Loader.java:2099) 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:152)
so how can i say my query is missing an index in this case?
source share