Hibernate???sql???
???????????? ???????[ 2014/5/27 11:51:25 ] ????????Hibernate ?????????? SQL???
????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??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11