JPA 别名问题 求解

惊变二十八天 2010-03-29 12:06:41
我使用了spring 和jpa(hibernate)
我调用 QueryTest()方法,这个方法里面有别名
为什么别名会不起作用

public void QueryTest(){
Query query =entityManager.createQuery("select o from Buyer o ");
query.getResultList();
}



下面是sql输出语句

select buyer0_.username as username0_, buyer0_.contact_id as contact8_0_, buyer0_.email as email0_, buyer0_.gender as gender0_, buyer0_.password as password0_, buyer0_.realname as realname0_, buyer0_.regTime as regTime0_, buyer0_.visible as visible0_ from Buyer buyer0_
...全文
303 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
一个称之为 JPQL 语句,一个是提交给 DBMS 执行的 SQL 语句,当然不一样了。
惊变二十八天 2010-03-29
  • 打赏
  • 举报
回复
问题已解决
惊变二十八天 2010-03-29
  • 打赏
  • 举报
回复
当我改成

public void QueryTest(){
Query query =entityManager.createQuery("select o.username from Buyer o ");
query.getResultList();
}



就不会出错了 为什么

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧