String lastTitle = "";
Movie movie = null;
try {
while( reader.ready() ){
String line = reader.readLine();
StringTokenizer tokenizer = new StringTokenizer(line, ";");
String title = tokenizer.nextToken();
String actorName = tokenizer.nextToken();
String roleName = tokenizer.nextToken();
if( !title.equals(lastTitle) ){
movie = PrototypeQueries.getMovie(pm, title);
if( movie == null ){
System.out.print("Movie title not found: ");
System.out.println(title);
continue;
}
lastTitle = title;
}
Actor actor = PrototypeQueries.getActor(pm, actorName);
if( actor == null ){
actor = new Actor(actorName);
pm.makePersistent(actor);
}
Role role = new Role(roleName, actor, movie);
}
} catch(java.io.IOException e){
System.err.println("Exception reading input file");
System.err.println(e);
return;
}