[hibernate-issues] [Hibernate-JIRA] Moved: (HHH-3321) @Size(min) fails in PostLoad

Emmanuel Bernard (JIRA) noreply at atlassian.com
Sat May 31 15:10:32 EDT 2008


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3321?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bernard moved ANN-724 to HHH-3321:
-------------------------------------------

        Affects Version/s:     (was: 3.3.0.ga)
                           3.2.6
              Component/s:     (was: validator)
                           core
    Requires Release Note: [Affirmative]
                      Key: HHH-3321  (was: ANN-724)
                  Project: Hibernate3  (was: Hibernate Annotations)

> @Size(min) fails in PostLoad
> ----------------------------
>
>                 Key: HHH-3321
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3321
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.6
>         Environment: hibernate 3.2.6.ga, hibernate-annotations 3.3.1.ga, hibernate-commons-annotations 3.0.0.ga, hibernate-entitymanager 3.3.1.ga, hibernate-validator 3.0.0.ga
> Linux (PClinuxOS), MySQL 5.x
>            Reporter: Albert Gorski
>
> I've standard parent-child mapping. 
> In parent I set validation for the childList list for minimum 1 and maximum 4 (max is not a problem)
> I create then a Parent and add Child to childCollection (one child added).
> When I call validation
> new ClassValidator<Person>(Person.class).getInvalidValues(myPerson);
> I see no exception/message - all is fine.
> The problem appears when I call entityManager.merge(myPerson) - there is an information that minimum child number is 1.
> I think it is a problem in PostLoad -> Parent entity is persisted and validated in PostLoad. Child entries are not yet persisted and it leads to exception.
> Is it possible to disable automatic validation in PostLoad or general when I want to validate manually?
> Is there any way around? 
> Parent-children classes:
> @Entity
> @Table(name = "parent")
> public class Parent {
>   @Id
>   @GeneratedValue(strategy = GenerationType.AUTO)
>   private Long id;
>   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy ="parent")
>   @Fetch(value = FetchMode.SUBSELECT)
>   @OptimisticLock(excluded = true)
>   @Size(min = 1, max = 4)
>   private List<Child> childList = new java.util.Vector<Child>(4, 1);
> }
> @Entity
> @Table(name = "child")
> public class Child extends AbstractEntity {
>   /** Serial UID. */
>   private static final long serialVersionUID = 1L;
>   @Id
>   @GeneratedValue(strategy = GenerationType.AUTO)
>   private Long id;
>   @ManyToOne(fetch = FetchType.LAZY)
>   @NotNull
>   private Parent parent;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list