????Hibernate?ж????????????????????????????????????????????????????????????JDBC?????????????????????????????????′????JDBC?????????
????PrepareStatement pre=connection.prepare(“select * from User where user.name=?”);
????pre.setString(1??”zhaoxin”);
????ResultSet rs=pre.executeQuery();
??????Hibernate???????????????????????????????????Hibernate?ж????????????????JDBC?????????????????Hibernate?й?????4?????????????????????????????
????A?? ?????????????
??????HQL????ж??????????????”:”???????????£?
????Query query=session.createQuery(“from User user where user.name=:customername and user:customerage=:age ”);
????query.setString(“customername”??name);
????query.setInteger(“customerage”??age);
???????????????:customername??:customerage???????????????customername??customerage???????Query????setXXX()?????趨?????????setXXX()??????????????????????????????????????????????????
????B?? ??????λ?e???
??????HQL??????????”?”?????????λ?????????£?
????Query query=session.createQuery(“from User user where user.name=? and user.age =? ”);
????query.setString(0??name);
????query.setInteger(1??age);
??????????setXXX()?????趨????????????????setXXX()?????????????????????????HQL????г????λ???????0??????????????????????????????????
????????????????У?????e???????????????????????????????????????????????????????????????????????????????λ?÷???????????????????????????????????????????????
????C?? setParameter()??????
??????Hibernate??HQL????п??????setParameter()???????????????????????′???
????String hql=”from User user where user.name=:customername ”;
????Query query=session.createQuery(hql);
????query.setParameter(“customername”??name??Hibernate.STRING);
??????????????????setParameter()??????????????????????????????????????????????????????????????????????????Щ????????setParameter()?????????????????Java??????2?????????????????????????????д?????????????????????????????????д??
????query.setParameter(“customername”??name);????????Щ???????д??????????????java.util.Date??????????????Hibernate?????????????????Hibernate.DATA????Hibernate.TIMESTAMP??