Code:
Query query = session.createSQLQuery("SELECT ifnull(c1.contentid, c.contentid)contentid, c1.contenttype," +
"ifnull(c.title,c1.title) title,b.body description," +
"ifnull(c1.creator,c.creator)," +
"ifnull (max(c.creationdate),max(c1.creationdate)) as creationdate," +
"c1.spaceid,count(distinct(c.contentid)) " +
"FROM Content c1 LEFT OUTER JOIN Content c ON c1.contentid = c.pageid " +
"INNER JOIN BodyContent b ON b.contentid = c1.contentid");
The above MySQL query runs well in MySQL Workbench.
When called through session.createSQLQuery, it throws below exception...
Code:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:79)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:104)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:393)
at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:582)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:508)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:524)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1817)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
..
..
..
The hibernate.cfg.xml looks like below
Code:
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://blrkiet0018pc:3306/connectedin_beta_notifications</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">Tec@Siemens18pc</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>
I request someone help in resolving this issue.
I have noticed that if I remove b.body description (in line 2 of code) the the query executes fine :-)
How should I resolve executing the query including b.body description?