-->
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.  [ 2 posts ] 
Author Message
 Post subject: No Dialect mapping for JDBC type
PostPosted: Fri Mar 16, 2007 2:51 pm 
Newbie

Joined: Sun Feb 18, 2007 3:18 pm
Posts: 3
Hi,

I am getting an org.hibernate.MappingException: "No Dialect mapping for JDBC type: -4" all day long.

The column type is "mediumblob" in a MySQL(5.0.21) DB. My SQL query is
Code:
String queryStringText = "SELECT t.old_text FROM text t WHERE t.old_id = " + id;
Object result = session.createSQLQuery(queryStringText).uniqueResult();


I used hibernate tools code generation to get POJOs and mappings. The generated mapping is

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 18.02.2007 20:08:34 by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
    <class name="de.sonivis.tool.mediawikiconnector.generated.Text" table="text" catalog="">
        <comment></comment>
        <id name="oldId" type="int">
            <column name="old_id" />
            <generator class="assigned" />
        </id>
        <property name="oldText" type="binary">
            <column name="old_text" not-null="true">
                <comment></comment>
            </column>
        </property>
        <property name="oldFlags" type="binary">
            <column name="old_flags" not-null="true">
                <comment></comment>
            </column>
        </property>
    </class>
</hibernate-mapping>


The generated POJO:
Code:
public class Text implements java.io.Serializable {

   private int oldId;

   private byte[] oldText;

   private byte[] oldFlags;

   public Text() {
   }

   public Text(int oldId, byte[] oldText, byte[] oldFlags) {
      this.oldId = oldId;
      this.oldText = oldText;
      this.oldFlags = oldFlags;
   }

   public int getOldId() {
      return this.oldId;
   }

   public void setOldId(int oldId) {
      this.oldId = oldId;
   }

   public byte[] getOldText() {
      return this.oldText;
   }

   public void setOldText(byte[] oldText) {
      this.oldText = oldText;
   }

   public byte[] getOldFlags() {
      return this.oldFlags;
   }

   public void setOldFlags(byte[] oldFlags) {
      this.oldFlags = oldFlags;
   }

}





Because I can not change the datatype in the DB I wrote a new dialect

Code:
public class MySQL5ExtraDialect extends MySQLDialect {

   /**
    *
    */
   public MySQL5ExtraDialect() {
      super();
      registerColumnType( Types.LONGVARBINARY, 16777215, "mediumblob" );
      registerColumnType( Types.LONGVARBINARY, 65535, "blob" );
      registerColumnType( Types.LONGVARBINARY, 255, "tinyblob" );
   }
}


because java.sql.Types -4 is LONGVARBINARY.

My Problem is - exception stays the same...

Errorlog:

Code:
16.03.2007 19:35:48 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.2
16.03.2007 19:35:48 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
16.03.2007 19:35:48 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
16.03.2007 19:35:48 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
16.03.2007 19:35:48 org.hibernate.cfg.Configuration configure
INFO: configuring from file: hibernate.cfg.xml
16.03.2007 19:35:48 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : de/sonivis/tool/mediawikiconnector/generated/Text.hbm.xml
16.03.2007 19:35:48 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: de.sonivis.tool.mediawikiconnector.generated.Text -> text
16.03.2007 19:35:49 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
16.03.2007 19:35:49 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
16.03.2007 19:35:49 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
16.03.2007 19:35:49 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
16.03.2007 19:35:49 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/psiwiki
16.03.2007 19:35:49 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.0.21-community
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.5 ( $Date: 2007-03-01 00:01:06 +0100 (Thu, 01 Mar 2007) $, $Revision: 6329 $ )
16.03.2007 19:35:50 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: de.sonivis.tool.mediawikiconnector.MySQL5ExtraDialect
16.03.2007 19:35:50 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
16.03.2007 19:35:50 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16.03.2007 19:35:50 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
16.03.2007 19:35:50 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
16.03.2007 19:35:50 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
16.03.2007 19:35:51 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured


and then

Code:
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
   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:369)
   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:1787)
   at org.hibernate.loader.Loader.doQuery(Loader.java:662)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.doList(Loader.java:2211)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
   at org.hibernate.loader.Loader.list(Loader.java:2090)
   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)
   at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
   at de.sonivis.tool.mediawikiconnector.MediaWikiNetworkLoader.loadWikiLinkNetwork(MediaWikiNetworkLoader.java:345)
   ... 30 more


Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 17, 2007 10:17 am 
Newbie

Joined: Sun Feb 18, 2007 3:18 pm
Posts: 3
Hmmmm... if I use a HQL-Query instead of a SQL-Query everything is fine:

Code:
String queryStringText = "select t.oldText from Text t where t.oldId = ?";
byte[] result = (byte[])session.createQuery(queryStringText).setInteger(0, id).uniqueResult();
String queryText = new String(result);


Sorry, I think it was my fault: If I use SQL-Queries hibernate does not use the mappings, right?


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