Results 1 to 3 of 3

Thread: BIG Hibernate Validator Problem

  1. #1

    Default BIG Hibernate Validator Problem

    Hi,

    I have a class Question with some fields and an one to many with FormattedTextChoice.
    Code:
    @Entity
    
    public class RadioBoxQuestion{
    	private String request;
    	...
    
    	@Size(min = 2, max = Question.MAXIMUM_CHOICES_PER_QUESTION)
    	@OneToMany(fetch = FetchType.EAGER, cascade =  CascadeType.ALL)
    	@JoinColumn(name = "RADIO_BOX_QUESTION_ID")
    	@OrderBy(clause = "position ASC")
    	@ForeignKey(name="CHOICES__RADIO_BOX_QUESTIONS_FK")
    	public Set<FormattedTextChoice> getRadioBoxChoiceSet() {
    		return radioBoxChoiceSet;
    	}
    	...
    	@AssertTrue
    	public boolean validateChoicePositions() {
    		 System.out.println("RadioBoxQuestion.validateChoicePositions(!!!!!!!)");
    		return Utils.validateElementsPosition(radioBoxChoiceSet);
    		
    	}
    }
    The problem is that whenever I try to update any of FormattedTextChoice objects and I do NOT modify the Question request field, the method annotated with @asserttrue (validateChoicePositions) is ignored!!!

    So a code like:
    ...
    myFormattedTextChoice = ...;
    myFormattedTextChoice.setPosition(9999);
    questioningDao.update(question);

    will result in corrupted data for me.


    But, if I modify also the request field, then will work as expected, and will execute the validateChoicePositions method.

    Any clues?

  2. #2

    Default

    any clues, guys?

    Thank you in advance

  3. #3

    Default

    Still no ideas?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •