Announcement Announcement Module
Collapse
No announcement yet.
Neo4j: JSR-303 Validation not working as expected Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neo4j: JSR-303 Validation not working as expected

    My user entity class:

    Code:
    @NodeEntity
    public class User {
    	@GraphId
    	private Long id;
    
    	@Indexed
    	@NotBlank
    	private String givenName;
    
    	@NotBlank
    	@NotNull
    	private String surname;
    
    	@Indexed(unique = true)
    	@NotEmpty
    	@NotBlank
    	private String username;
    ...
    This fails (no validation exception is thrown):

    Code:
    	@Test(expected = ValidationException.class)
    	public void shouldThrowValidation() {
    		User user = new User();
    		userRepository.save(user);
    	}
    This DOES NOT fail (validation exception is thrown):
    Code:
    	@Test(expected = ValidationException.class)
    	public void shouldThrowValidation() {
    		User user = new User();
                    user.setUsername(null);
    		userRepository.save(user);
    	}
    What is going on here? I did some debugging and noticed that the validation listener only fires when the value of the property is somehow changed. Is that really the case? How can I make validation work for objects with their default (invalid) values?

    Thanks.

  • #2
    Sorry I forgot the relevant version info...

    Neo4J - 1.7
    SDN - 2.1.0.RC1

    Comment

    Working...
    X