Java?????hibernate????????
???????????? ???????[ 2015/4/20 11:53:04 ] ????????Java ??ó??? ???????
????????how??Hibernate?????????????????
????1. ???????????:
????evit(Object obj) ?????????????????????????????????????????????????????????????????????????????????????
????clear() ??????????е????г?????????????????????????????
????contains(Object obj) ?ж?????????????????????????С?
????flush() ????????????????????????????????????????
????2.??????????? save()????session???????save()??????????????????????????session??????С? get()??load()????session???????get()??load()??????????????????????????????????session??????С? ???HQL??QBC?????????в???????
public class Client
{
public static void main(String[] args)
{
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = null;
try
{
/*???????????*/
tx = session.beginTransaction();
/*????????л??id="402881e534fa5a440134fa5a45340002"??Customer????*/
Customer customer1 = (Customer)session.get(Customer.class?? "402881e534fa5a440134fa5a45340002");
System.out.println("customer.getUsername is"+customer1.getUsername());
/*??????*/
tx.commit();
System.out.println("-------------------------------------");
/*?????????????*/
tx = session.beginTransaction();
/*????????л??id="402881e534fa5a440134fa5a45340002"??Customer????*/
Customer customer2 = (Customer)session.get(Customer.class?? "402881e534fa5a440134fa5a45340002");
System.out.println("customer2.getUsername is"+customer2.getUsername());
/*??????*/
tx.commit();
System.out.println("-------------------------------------");
/*???????get()?????????????????????????*/
System.out.println("customer1 == customer2 result is "+(customer1==customer2));
}
catch (Exception e)
{
if(tx!=null)
{
tx.rollback();
}
}
finally
{
session.close();
}
}
}
???????
Hibernate:
select
customer0_.id as id0_0_??
customer0_.username as username0_0_??
customer0_.balance as balance0_0_
from
customer customer0_
where
customer0_.id=?
customer.getUsername islisi
-------------------------------------
customer2.getUsername islisi
-------------------------------------
customer1 == customer2 result is true
??????????????????????SELECT SQL???????customer1 == customer2 result is true???????????????????????????????????????ε???get()?????? Hibernate???????????????иò????????????У?Hibernate????SELECT???????????????????????????????????У?????′?????????ε???get()??????Hibernate???????????????иò???????????????иò???????????????????????????????м?????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
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????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????