10

I'm working on a entity library. I put some bean-validation annotations on my Entities.

I strongly believe a bean-validation implementation in on the class path. @javax.validation.constraints.NotNull works and @javax.validation.constraints.AssertTrue doesn't work.

class MyEntity {

    @AssertTrue // does't work
    public boolean hey() {
        return false;
    }

    @NotNull // works; violation while persist
    private String some;
}

What possibly did I do wrong with it?

I uses org.hibernate:hibernate-validator and changing it with org.apache.bval:bval-jsr doesn't make any difference.

UPDATE

The method is actually invoked. I check the log.

Here comes my method.

@AssertTrue(message = "a property must be eclusively system or owned")
private boolean execlusivelySystemOrOwned() {
    logger.info("execlusivelySystemOrOwnded()");
    final boolean result = system ^ (getOwner() != null);
    logger.log(Level.INFO, "result: {0}", result);
    return result;
}
Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184

1 Answers1

21

I think I found the answer.

https://stackoverflow.com/a/12950573/330457

I had to rename the method to isExeclusivelySystemOrOwned.

That's why it's called Bean-Validation.

Community
  • 1
  • 1
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184