Getting more into it, I can describe additionally:
1) I write and read via a servlet, where I do a "_BaseRootDAO.initialize();" centrally in the init-method. But I also tried to do this initialization before any db-call.
2) I write my dataset to the db and - for testing reasons - read it immediately after that. This works stable.
3) Then I leave the servlet and re-enter it with a new read-statement. This will fail with the HibernateException "No row with the given identifier exists". At the same time, I can access this very row with a load from my Eclipse-based testenvironment.
The servlet is basically very simple:
Code:
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
_BaseRootDAO.initialize();
} catch (HibernateException e1) {
System.out.println( "Exception initializing Hibernate ProcessOrderSERVLET.init. Msg: " + e1.getMessage() );
}
}
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String reqPar = request.getParameter("request");
if (reqPar.equals("writeit")) {
writeIt(request, response);
} else
if (reqPar.equals("readit")) {
readIt(request, response);
}
}
private void writeIt(HttpServletRequest request,
HttpServletResponse response){
MyObject mo = new MyObject();
... populate object ...
Integer IdStr = BaseMyObjectDAO.getInstance().save( mo );
//for testing... (works)
MyObject o = BaseMyObjectDAO.getInstance().load( ord.getId() );
try{
System.out.println( "RELOAD ID: " + o.getId() );
} catch (Exception e){
System.out.println( "Could not be loaded: Id: " + ord.getId().intValue() );
}
}
private void readIt(HttpServletRequest request,
HttpServletResponse response){
try{
MyObject obj = BaseMyObjectDAO.getInstance().load( new Integer( request.getParameter("id" ) ) );
... do something with it ...
} catch ( HibernateException e ){
//if I call the just saved row, it will alway jump to this point when there was no other writing action inbetween
}
}
The behavior is sooo confusing...
Thanks for any valueable thought.
Klaus