如题,传递参数是中文就报异常
public List<VoteSubject> getSubjectByTitle(String keywords){
session=super.getSession();
Query query=session.createQuery("from VoteSubject where vsTitle like :title");
query.setParameter("title", "%"+keywords+"%");
return query.list();
}
public static void main(String[] args) {
List<VoteSubject> list=new VoteSubjectDaoImpl().getSubjectByTitle("a");
for (VoteSubject voteSubject : list) {
System.out.println(voteSubject.getVsTitle());
}
}
这里传递一个英文参数a,hibernate没有报错,正常查询
如果参数传递中文
public static void main(String[] args) {
List<VoteSubject> list=new VoteSubjectDaoImpl().getSubjectByTitle("中文");
for (VoteSubject voteSubject : list) {
System.out.println(voteSubject.getVsTitle());
}
}
这里传递中文参数,发生以下的异常
2014-11-19 21:47:40 org.hibernate.util.JDBCExceptionReporter logExceptions
警告: SQL Error: 1460, SQLState: 72000
2014-11-19 21:47:40 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: ORA-01460: unimplemented or unreasonable conversion requested
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at dao.impl.VoteSubjectDaoImpl.getSubjectsByTitle(VoteSubjectDaoImpl.java:29)
at dao.impl.VoteSubjectDaoImpl.main(VoteSubjectDaoImpl.java:35)
Caused by: java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:622)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:180)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:419)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:895)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:451)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:985)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2928)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 7 more
版本是myEClipse里的hibernate3.2版本,求助