Hello
I hope someone can show me what I am doing wrong....
I have a class that finds a specific team within a league and then deletes
the team. The team (and all the relationships) are deleted in the database
(MySQL 4) - I can go & have a look and all is as expected. The problem is
that when I run a query on the league to find all the teams that are in it,
the team that has been deleted still comes up in the list. If I shut the
browser down and start it back up again, the List leagues =
ctxt.performQuery(query); returns what is actually in the database, i.e. the
desired result.
The basic code is here - I have stripped out all the error checking and what
is left is what runs when there is a valid team to delete.
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HttpSession session = request.getSession();
setCtxt(session);
String action = request.getParameter("action");
String teamname = request.getParameter("teamName");
String leagueName = request.getParameter("leagueName");
Teacher currentTeacher = (Teacher)
session.getAttribute(Constants.TEACHER_KEY);
DataContext ctxt = getCtxt();
// find the team to delete and delete it
setTeams(findTeams(teamname));
Team team = (Team) getTeams().get(0);
ctxt.deleteObject(team);
ctxt.commitChanges();
// this part returns the data that was present before the
// ctxt.deleteObject(team);
// ctxt.commitChanges();
// above was run
SelectQuery prototype = (SelectQuery)
ctxt.getEntityResolver().getQuery("SelectSpecificTeachersLeague");
Map params = new HashMap();
params.put("leagueName", leagueName);
params.put("teacherEmail", currentTeacher.getEmail());
SelectQuery query = prototype.queryWithParameters(params, true);
List leagues = ctxt.performQuery(query);
League updatedLeague = (League) leagues.get(0);
List teams = updatedLeague.getToTeam();
request.setAttribute("teams", teams);
}
private List findTeams(String teamname) {
DataContext ctxt = getCtxt();
Expression qualifier = ExpressionFactory.matchExp("teamName", teamname);
SelectQuery query = new SelectQuery(Team.class, qualifier);
List teams = ctxt.performQuery(query);
return teams;
}
Thank you for your help
Callum
_____________________________________________________________________
This e-mail has been scanned for viruses by MessageLabs.
This archive was generated by hypermail 2.0.0 : Thu Nov 04 2004 - 07:02:57 EST