from Area as a where a.country.id="+countryid

解决方案 »

  1.   

    from Area as a where a.country="+countryid
    hibernate知道把所给的值换成对象的主键
    最好用动态查询,也就是"?"
      

  2.   

    主外键关系,只要你在hibernate配置文件里配置了一对一或多对一等这些后hibernate会自动去判断,你不用管,你只要给他一个值~~.
      

  3.   

    from Area as a where a.country.id="+countryid
    这样保证不会错
      

  4.   

    from Area as a where a.country=?.setString(0,10);
    就可以了
    hibernate只要hbm文件配置了关系,就会自动转换
    没你想的那么难
      

  5.   

    "from Area as a where a.country.id =:countryid"
    query.setInteger("countryid", countryid );