-->
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: limited string length in createSQLQuery
PostPosted: Mon Mar 29, 2010 4:30 pm 
Beginner
Beginner

Joined: Sat Jan 05, 2008 7:33 am
Posts: 26
Does anybody knows if there is a limit to the string length that can be passed as argument to createSQLQuery

if I print the string before calling query.list();
I get a 1320 long string
and the error:
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)

Note that the string seems to be parsed ok because if I do not set the : specified parameters or if I set a non existent one, I get a proper error:
org.hibernate.QueryException: Not all named parameters have been set: [m_date] ... <full query printed here>
or
org.hibernate.QueryParameterException: could not locate named parameter [m1_date]

and if I put some additional character at the end of the query so 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

Of course if I copy paste my query in a MySQL client CLI I get the proper result OK

So seems like there is something else and of course I can not reduce the size of the query string artificially/easily


Top
 Profile  
 
 Post subject: Re: limited string length in createSQLQuery
PostPosted: Thu May 20, 2010 3:26 am 
Beginner
Beginner

Joined: Sat Jan 05, 2008 7:33 am
Posts: 26
for your information I managed to get the real problem and its solution
It did not concern the query length at all but only the fact that my query contained a union
for which Hibernate does not really know what that should be associated to the different returned fields

The solution consists in calling
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);
before any
query.setParameter(...)
& 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.