-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: createSQLQuery exception when using 2 tables [SOLVED]
PostPosted: Tue Mar 05, 2013 5:28 am 
Newbie

Joined: Tue Mar 05, 2013 5:22 am
Posts: 3
I'm trying to use hibernate to return data from multiple tables from my database. The query works fine on my SQL server, however it does not seem to work with hibernate's createSQLQuery.

Code

Code:
Query threadQuery = session.createSQLQuery("SELECT CONCAT(t.lastposter) as lastposter, t.lastpost, t.title, t.threadid, t.lastpostid, t.firstpostid, t.forumid, p.pagetext FROM vbulletin.thread AS t INNER JOIN vbulletin.post AS p ON p.postid = t.firstpostid WHERE t.open != 10 AND t.visible = 1 AND t.forumid != 19 AND t.forumid != 20 ORDER BY t.lastpost DESC").setResultTransformer(Transformers.aliasToBean(VbulletinThread.class));


Exception
Code:
org.springframework.orm.hibernate3.HibernateSystemException: No Dialect mapping for JDBC type: -1; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
   at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
   at...


The aliases match the fields of my class.
Note: it works fine when I remove p.pagetext from the query.

I don't see the problem, maybe you guys can help?


Last edited by ogbrandon on Fri Mar 15, 2013 7:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: createSQLQuery exception when getting data from 2 tables
PostPosted: Thu Mar 07, 2013 4:48 am 
Newbie

Joined: Tue Mar 05, 2013 5:22 am
Posts: 3
bump


Top
 Profile  
 
 Post subject: Re: createSQLQuery exception when getting data from 2 tables
PostPosted: Fri Mar 15, 2013 6:46 am 
Newbie

Joined: Tue Mar 05, 2013 5:22 am
Posts: 3
Edit: I have found the solution.

It had nothing to do with the fact, that I am using 2 tables.

I had to convert the database char to a string to make it work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.