Take the 2-minute tour ×

What is wrong with the following piece of code?

    public void preSave() throws DuplicatePinException  {
        for (PinBoard pb : board.pins) {
            if (pb.pin.id.equals(this.pin.id)) {
                throw new DuplicatePinException();

This method is in my PinBoard class. I wanted a quick way to validate that no duplicate entries can be saved. If I include the method, however, nothing gets saved. Ever. I traced it down to the board.pins. I assume that pins is a lazy loaded collection by default, so it might be that forcing it to initialize at the time of saving is screwing up something.

I am using Play 1.2.5

share|improve this question
Is the console print the log Logger.info("PRESAVE")? –  Wayan Wiprayoga Mar 22 '13 at 3:57
@iwawiwi yes, it does –  user1107412 Mar 22 '13 at 7:09
Okay. If you do List<PinBoard> piboard_list = board.pins before loop. and loop over pinboard_list is it still not persist? If still not work. I would recomended you to put validation code in the controller and do that before calling save() method. –  Wayan Wiprayoga Mar 22 '13 at 12:03

1 Answer 1

Im not sure about play 1 but in play 2 @PrePersist is not included, so method is never getting called

share|improve this answer

Your Answer


