-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping MySQL Text type for FullText search
PostPosted: Fri Jul 07, 2006 10:47 am 
Newbie

Joined: Wed Mar 29, 2006 5:21 am
Posts: 4
Hi, I've a problem with a MySQL query fulltext to search a word into a text field on DB..

If I set the field as VARCHAR 255, all works very well, but I need more than 255 chars for this field, so cannot use VARCHAR....

If I use TEXT with 500 char, I receive "org.hibernate.MappingException: No Dialect mapping for JDBC type: -1"

I can use VARCHAR or TEXT types only for fulltext search..

Can you help me?

thanks



Hibernate version: 3.1.3

Mapping documents:
<class name="it.occasioni.dbmapping.Annuncio" table="annunci" catalog="occasioni">
<id name="idAnnuncio" type="java.lang.Integer">
<column name="idAnnuncio" />
<generator class="native" />
</id>
<property name="testo" type="java.lang.String">
<column name="testo" length="500" not-null="true" />
</property>
.
.
.other properties

SQL Native Query for Spring:

<sql-query name="getAnnunciCategoriaSelezionataByChiave"><![CDATA[
SELECT DISTINCT a.*
FROM annunci a
WHERE MATCH(testo) AGAINST(:chiave)
]]>
</sql-query>



Full stack trace of any exception that occurs:
2006-07-07 16:35:38,968 [http-8080-Processor24] ERROR it.occasioni.actions.PortaleAction - Ricerca annuncio per categoria: No Dialect mapping for JDBC type: -1; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -1

Name and version of the database you are using:
EasyPHP 1.8 (MySQL 4.1.9)
Apache Tomcat/5.0.28
MySQL connector 3.1.13
JDK 1.4.2.11
Struts/Spring

The generated SQL (show_sql=true):
CREATE TABLE `annunci` (
`idAnnuncio` int(8) NOT NULL auto_increment,
`testo` text NOT NULL,
`dataInserimento` date NOT NULL default '0000-00-00',
`dataUltimaModifica` date NOT NULL default '0000-00-00',
`tipoAnnuncio` int(1) NOT NULL default '0',
`numeroPubblicazioni` int(3) NOT NULL default '1',
`note` varchar(80) default NULL,
`idStato` int(1) NOT NULL default '0',
PRIMARY KEY (`idAnnuncio`),
FULLTEXT KEY `testo` (`testo`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 12:59 pm 
Newbie

Joined: Tue Apr 19, 2005 3:16 pm
Posts: 18
Hi, fedo. I think the reason Hibernate is complaining about your TEXT datatype is that you're not providing it with any clues about the column's type in your mapping document. Try changing:

Code:
<property name="testo" type="java.lang.String">
   <column name="testo" length="500" not-null="true" />
</property>


to:
Code:
<property name='testo" type="string">
   <column length="500" sql-type="CLOB" not-null="true"/>
</property>


I'm not sure the "length" attribute will do anything, since I wasn't aware you could constrain MySQL's TEXT datatype, but if I recall correctly, Hibernate will understand how to translate the "CLOB" type to MySQL. Unfortunately, I don't currently have MySQL installed anywhere locally to test this theory.

Be sure to let me know if this worked! :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 10:02 am 
Newbie

Joined: Wed Mar 29, 2006 5:21 am
Posts: 4
Thanks, but doens't work..

I've created my dialect:

Code:
import java.sql.Types;
import org.hibernate.Hibernate;


public class MySQLDialectOccasioni extends org.hibernate.dialect.MySQLDialect{

   
   public MySQLDialectOccasioni() {
      super();
      registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName() );
      }    
   
}


and I've mapped it into hibernate config:

Code:
<prop key="hibernate.dialect">it.occasioni.config.MySQLDialectOccasioni</prop>



NOW WORKS!!!

Bye


Top
 Profile  
 
 Post subject: Re: Mapping MySQL Text type for FullText search
PostPosted: Thu Feb 20, 2014 12:59 am 
Newbie

Joined: Thu Feb 20, 2014 12:50 am
Posts: 1
The prop tag that u have used how to incorporate that in the hibernate config file
and should i use that CLOB code as well with the mysql dialect


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