EJB3.0中查询boolean值的方法
百度广告
我定义了一个类:HibernateBooleanDemo
String hql = "from HibernateBooleanDemo where isEnabled=false";
Transaction t = s.beginTransaction();
List list = q.list();
System.out.println(((HibernateBooleanDemo)list.get(0)).isEnabled());
HibernateSessionFactory.closeSession();
一直不明白是什么原因。请大家指点
若"from HibernateBooleanDemo where isEnabled=false";写为"from HibernateBooleanDemo where enabled=false";错误
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3124)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1262)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
... 8 more
String hql = "from HibernateBooleanDemo where isEnabled=false";
Transaction t = s.beginTransaction();
List list = q.list();
System.out.println(((HibernateBooleanDemo)list.get(0)).isEnabled());
HibernateSessionFactory.closeSession();
一直不明白是什么原因。请大家指点
若"from HibernateBooleanDemo where isEnabled=false";写为"from HibernateBooleanDemo where enabled=false";错误
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3124)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1262)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
... 8 more
from HibernateBooleanDemo h where h.enabled=false
【AmethystWish】:
Exception in thread "main" org.hibernate.QueryException: could not resolve property: enabled of: org.acman.demo.HibernateBooleanDemo [from org.acman.demo.HibernateBooleanDemo h where h.enabled=false]
编辑推荐:
下载Word文档
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>