Hi,
im developping a simple webservice : void deleteCar(int idCar)
Currently, what im doing in my code is :
1-to load the cardObjet by id :session.get(Car.class,idCar)
2-to remove it : session.delete(carLoaded)
So for an operation i have at least 2 sql query (n+1 problem ?)
I dont even speak about any not lazy relationship in the car that will resultat in more sql queries.
i have tought to use an HQL query that :
1-will check by the id if the car exist with a lockMode.UPGRADE (boolean carDao.exist(int id))
2-if the car exist, use a hql query like this one :"delet from Car c where c.id=?"
But how the cache might react to this (we will use ehCache)
In the first solution, i'm almost sure the car will be evicted from the 2nd level cache.
In the 2nd solution( with hql query), the cache will be smart enough to remove the car loaded in the 2nd level cache ?