简体   繁体   中英

playframework execution exception

I'm working on this little "website" and I can make a list of ploegen. But I can't delete them. everytime I click the delete button I get this error message:

[PersistenceException: ERROR executing DML bindLog[] error[Unique index or primary key     
violation: "PRIMARY_KEY_4 ON PUBLIC.PLOEG(ID)"; SQL statement:\n insert into ploeg 
(id, naam, punten) values (?,?,?) [23505-172]]]

This is the code I use to make the delete button:

@form(routes.Application.deletePloeg(ploeg.id)) {
     <input type="submit" value="Delete deze ploeg">
}

Than this is the method:

public static Result deletePloeg(Long id) {
     Ploeg.delete(id);
     return redirect(routes.Application.ploegen());
}

En this is the function within my Ploeg.class:

public static void maak(Ploeg ploeg) {
     ploeg.save();
}

public static void delete(Long id) {
     find.ref(id).delete();
}

The error I get is about the line: ploeg.save();

I really don't find the problem, I press the delete button but it gives an error about me saving a ploeg. So if someone could tell me what I do wrong and how I can fix it. Thanks!

You can't receive an instance of Ploeg as an input parameter of your action.

Your code should probably look something like:

public static void maak() {
     Ploeg ploeg = new Ploeg();
     ploeg.save();
}

EDIT

I changed it like this and that works. Only when I try to delete a ploeg It doesn't delete it but makes a new one. That new ploeg doesn't have a name but it is inserted in my table.

public static void maak(Ploeg ploeg) {
     ploeg = new Ploeg();
     ploeg.save();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM