Announcement Announcement Module
Collapse
No announcement yet.
Automatic Bean Validation in Roo Entities Problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic Bean Validation in Roo Entities Problem

    Hi,

    I read this article (http://www.javabeat.net/articles/pri...article_id=295) and find that, in session "Using bean validation in Roo entities" the author says that "...Spring Roo supports automatic validation of Roo Entities, if annotated with Bean Validation annotations. The Roo entities are automatically validated when a persist or merge method call is executed...".

    My question is what should I do to enable this feature? I have trying the example in the article, but the entity I create doesn't get validation invoked when I call its persist() method.

    I saw the ITD generated by Roo for the entity and can't see any code that could invoke the bean validation mechanism (no @PrePersist method, no Validator creation, and so on..).

    Does Roo really automatic validate roo entities when Entity.persist() method is called?

    Here is a sample code that I'm using to verify this feature.

    Code:
    @RooEntity
    public class User {
    
           @NotNull
           private String name
    }
    
    @RooIntegrationTest(entity = User.class, count=false, merge=false, findEntries=false, flush=false, persist=false)
    public class UserIntegrationTest {
    
        @Test
        public void testPersist_NullName() {
        	User u = new User();
        	try {
    	     u.persist();
    	     Assert.fail("persisted - null name");
    	} catch (ConstraintViolationException e) {
               //JSR 303 validation exceptions expected
            }
        }
    
    }
    I'm using roo 1.1.4-RELEASE. The above test fails.

    Any Help?
Working...
X