-->
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: limite de longueur de chaine pour createSQLQuery
PostPosted: Mon Mar 29, 2010 4:35 pm 
Beginner
Beginner

Joined: Sat Jan 05, 2008 7:33 am
Posts: 26
Est ce que qqn sait s'il y a une longueur maximale pour la chaine SQL pouvant etre passee a createSQLQuery ?

si j'affiche la chaine juste avant d'appeler query.list();
j'obtiens une chaine de 1320 de long
et l'erreur suivante:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
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:370)
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:1796)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
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)

A noter que la chaine semble etre parcourue correctement ca si j'oublie de specifier certains parametres ou que j'en positionne un qui
n'existe pas j'obtiens des erreurs coherentes:

org.hibernate.QueryException: Not all named parameters have been set: [m_date] ... <query complete imprimee ici>
ou
org.hibernate.QueryParameterException: could not locate named parameter [m1_date]

et si j'avoute qq caracteres a la fin de la chaine String myQuery += " ww";
org.hibernate.exception.SQLGrammarException: could not execute query ...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ww' at line 1

Bien sur en copiant la chaine SQL dans un CLI MySQL j'obtiens aussi le bon resultat

Il y a donc qqc qui empeche ma query de fonctionner et il m'est impossible de reduire sa taille


Top
 Profile  
 
 Post subject: Re: limite de longueur de chaine pour createSQLQuery
PostPosted: Thu May 20, 2010 3:24 am 
Beginner
Beginner

Joined: Sat Jan 05, 2008 7:33 am
Posts: 26
pour information j'ai fini par trouver le probleme et sa solution
Cela ne vient absolument pas de la longueur de la chaine mais du fait que ma query contient une union
pour laquelle hibernate ne sait pas trop quels types associer aux differents champs retournes

La solution est d'appeler
query.addScalar("dep_name", Hibernate.STRING).addScalar("db_id", Hibernate.BIG_INTEGER).addScalar("name", Hibernate.STRING).addScalar("size", Hibernate.BIG_INTEGER).addScalar("installed_size", Hibernate.BIG_INTEGER).addScalar("fullname", Hibernate.STRING);
avant d'appeler
query.setParameter(...)
et query.list(...)


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.