java - how to handle entity manager can not find an object instance case? -
i have sceneario in have check if onject instance exist in entity manager. works fine when instance eexists throws null pointer exception when doesn't. when doesn't have thing. how can catch state? tried try catch, doesn't work.
sorry when asking question on way , trying type in different device used to. code is:
ajpacontroller ajpacontroller; aclass aclass = ajpacontroller.find((integer.parseint(request.getparameter("id"))); try{ if(ajpacontroller.contains(aclass)){ response.sendredirect("gosomewhere.com"); } } catch (java.lang.nullpointerexception r){ response.sendredirect("gosomewhereelse.com"); } i might have logical mistake in trying first find , contains method, couldn't find better solution. in advance.
you can check if entity managed (within persistence context) of contains method of entitymanager
Comments
Post a Comment