-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Envers @ManyToMany audit includes removed entities
PostPosted: Tue Dec 06, 2011 8:47 am 
Newbie

Joined: Tue Dec 06, 2011 8:28 am
Posts: 1
Code:
@Entity
@Audited
public class Template {
    @Id
    Long id;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "template_section")
    List<Section> sections;

    ...
}

@Entity
@Audited
public class Section {
    @Id
    Long id;

    ...
}


Steps Taken
-----
1) Create a few sections
Section A (rev 1)
Section B (rev 2)
Section C (rev 3)

2) Create a template with these sections
Template A (rev 4)
Section A, Section B, SectionC (join table rev 4)

3) Update the section and remove a section
Template A (rev 5)
Section A, Section B (join table rev 5)

When I load revision 5 of the template I would expect a template with only two sections, instead it returns a template with all three. I think the key is in the generate SQL which specifies a revision <= 5.

The template_sections_aud join table contains

Code:
REV     STATEMENT     SECTIONS     REVTYPE
------------------------------------------
5          1             1           0
5          1             2           0
4          1             1           0
4          1             2           0
4          1             3           0


The generated SQL query to pull back the sections returns (column names changed to improve readability):

Code:
TEMPLATE_SECTION_REV    TEMPLATE_ID    TEMPLATE_SECTION_ID    SECTION_ID    SECTION_REV
---------------------------------------------------------------------------------------
     5                    1                    1                1             1        <- Section A
     5                    1                    2                2             2        <- Section B
     4                    1                    3                3             3        <- Section C (Shouldn't be here)


Have I setup my relationship incorrectly? Why does the revisioned entity have all three sections?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.