Bug 1326334 - [GSS](6.4.z) Group sequences don't honor inheritance relationships properly
Summary: [GSS](6.4.z) Group sequences don't honor inheritance relationships properly
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.4.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: CR1
: EAP 6.4.9
Assignee: Gail Badner
QA Contact: Martin Simka
URL:
Whiteboard:
Depends On: 1326333
Blocks: 1307264 eap649-payload
TreeView+ depends on / blocked
 
Reported: 2016-04-12 12:58 UTC by Tom Ross
Modified: 2019-11-14 07:46 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1326333
Environment:
Last Closed: 2017-01-17 12:56:39 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tom Ross 2016-04-12 12:58:47 UTC
Backport of HV-1057 (https://hibernate.atlassian.net/browse/HV-1057)

Assuming the following
public interface Min {}

public interface Max extends Min {}

@GroupSequence({Max.class, A.class})
public class A {
    @NotNull(groups=Max.class)
    public String foo;

    @NotNull(groups=Min.class)
    public String bar;
}

public class B {
    @NotNull(groups=Max.class)
    public String foo;

    @NotNull(groups=Min.class)
    public String bar;
}
The following code returns as expected
assert validator.validate(new B(), Max.class, B.class).size() == 2
But the following fails
// bar is ignored as Min is not considered when Max is evaluated for default sequence
// so size == 1
assert validator.validate(new A(), Max.class, A.class).size() == 2
Note that the actual test used group sequence provider but that's not relevant I think.

Comment 1 Tom Ross 2016-04-12 12:59:43 UTC
Group sequences may contain groups which are inherited from another group:
public class Try {

    @NotNull(message = "field1", groups = BaseComponent.class)
    public String field1;

    @NotNull(message = "field2", groups = Component.class)
    public String field2;

    @NotNull(message = "field3", groups = OtherComponent.class)
    public String field3 = "";

    public interface BaseComponent {}
    public interface Component extends BaseComponent {}
    public interface OtherComponent {}

    @GroupSequence({ Component.class, OtherComponent.class })
    public interface GlobalCheck {}
}
A validation validator.validate( new Try(), Try.GlobalCheck.class ); should yield the two constraints on field1 and field2 (as both constraints are in the Component group, which extends the BaseComponent group.
The current implementation returns only the constraint on field2, though. The reason being that all three groups which form the sequence are "flattened out", thus loosing the information that Component and BaseComponent need to be considered as one atomic unit here.

Comment 5 Jiří Bílek 2016-06-27 13:22:54 UTC
Verified with EAP 6.4.9.CP.CR2

Comment 6 Petr Penicka 2017-01-17 12:56:39 UTC
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.


Note You need to log in before you can comment on or make changes to this bug.