-->
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.  [ 6 posts ] 
Author Message
 Post subject: no dialect mapping for jdbc type: -1?
PostPosted: Tue Dec 05, 2006 6:34 am 
Newbie

Joined: Thu Nov 23, 2006 11:08 am
Posts: 14
hi, i am sending a sql query string to the database using :

Code:
SQLQuery sql = session.createSQLQuery(sqls);
List l = sql.list();


this is my query:


SELECT p.produktnavn, p.produktlink, p.bildesti, k.knavn, p.id, p.beskrivelse FROM produkt p JOIN produktkategori pk ON p.id=pk.produktid JOIN kategori k ON pk.kategoriid=k.id JOIN produktfarge pf ON p.id=pf.produktid JOIN farge f ON pf.fargeid=f.id JOIN merke m ON p.merkeid = m.id JOIN publikasjon pu ON p.publikasjonid WHERE p.pris LIKE '%foo%' OR p.beskrivelse LIKE '%foo%' OR p.produktnavn LIKE '%foo%' OR f.fargenavn LIKE '%foo%' OR k.knavn LIKE '%foo%' OR m.merkenavn LIKE '%foo%' OR pu.pnavn LIKE '%foo%' ORDER BY k.knavn ASC;


the bold term brings me the above error message (see title of posting). it works perfect when i delete the bold stuff. i searched the net for that, but i didnt find much :-o. anyone any idea how i could fix that?

thanks in advance :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 10:02 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
This is the integer value in the java.sql.Types class:

Code:
public final static int LONGVARCHAR    =  -1;


Your Dialect class probably misses this mapping.
What Dialect are you using ?

You may need to write a subclass of this and add the mapping
for LONGVARCHAR yourself. Example:

Code:
registerHibernateType(Types.DECIMAL, Hibernate.BIG_DECIMAL.getName());

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 5:51 am 
Newbie

Joined: Thu Nov 23, 2006 11:08 am
Posts: 14
hi, how can i find out, what dialect im using? i just dont understand, why ut works with some columns and it doesnt with few others. is there an easier way get rid of this problem?

regards:)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 8:24 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
An easier way for some may be to change the SQL-Type of the column.
i.e. change you database table.
The Dialect class can be specified in you hibernate.cfg.xml file, like:

Code:
<property name="dialect">org.hibernate.dialect.DB2Dialect</property>

In this example you can create a subclass of org.hibernate.dialect.DB2Dialect.

_________________
dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 10:07 am 
Newbie

Joined: Thu Nov 23, 2006 11:08 am
Posts: 14
hi, the dialect is set already. this is the line:


<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>


im using mysql so it should work. the type of the column is string and it works with other string columns....?

regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 1:43 pm 
Newbie

Joined: Wed Dec 06, 2006 10:52 pm
Posts: 5
You can figure out which column is giving you the problem by doing something like this:

SELECT <column_name> from <table_name> for each of the columns in the table

The problem is due to hibernate unable to map the correct column datatype. I guess you can fix this problem by fixing the datatype in MySQL

Hope that helps.
K


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.