Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
when i change from sybase database to mysql the bind parameters don't work correclty i don understand what is the problem but the generated sql appears with :parameter then ? point.
tnx for the help
Hibernate version:
3.0.5
Code between sessionFactory.openSession() and session.close():
...
size = dao.getSociSize(" where UPPER(socio.cognome || ' ' || socio.nome) like :txt", new String[] {"txt"}
, new Object[] {searchTxt});
...
public int getSociSize(String whereClause, String[] names, Object[] params)
throws DAOException {
try {
Query q = getQuery("select count(*) from sic.business.Socio as socio", whereClause, "",names,params);
return( (Integer) q.iterate().next()).intValue();
}
catch(HibernateException ex) {
throw new DAOException(ex);
}
}
protected Query getQuery(String fromClause, String whereClause, String orderClause, String[] names,
Object[] parameters)
throws HibernateException {
Query q = getQuery(fromClause, whereClause, orderClause);
for(int i = 0; i < names.length; i++) {
if(parameters[i].getClass().isArray()) {
q.setParameterList(names[i], (Object[]) parameters[i]);
}
else if(parameters[i] instanceof Collection) {
q.setParameterList(names[i], (Collection) parameters[i]);
}
else {
q.setParameter(names[i], parameters[i]);
}
}
return q;
}
Full stack trace of any exception that occurs:
12:25:35,553 DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:25:35,553 DEBUG SQL:324 - /* select count(*) from sic.business.Socio as socio where UPPER(socio.cognome || ' ' || socio.nome) like :txt */ select count(*) as col_0_0_ from socio socio0_ where (UPPER(socio0_.soc_cognome||' '||socio0_.soc_nome)like ? )
Hibernate: /* select count(*) from sic.business.Socio as socio where UPPER(socio.cognome || ' ' || socio.nome) like :txt */ select count(*) as col_0_0_ from socio socio0_ where (UPPER(socio0_.soc_cognome||' '||socio0_.soc_nome)like ? )
12:25:35,616 DEBUG AbstractBatcher:378 - preparing statement
12:25:35,616 DEBUG AbstractBatcher:306 - about to open ResultSet (open ResultSets: 0, globally: 0)
12:25:35,631 DEBUG AbstractBatcher:313 - about to close ResultSet (open ResultSets: 1, globally: 1)
12:25:35,631 DEBUG AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:25:35,631 DEBUG AbstractBatcher:416 - closing statement
Name and version of the database you are using:
Mysql 4.1