On 17/05/2012 21:43, Carlucci, Tony wrote:
Hello Rave devs, I came across a bug related to the shared spaces code that I'm 
not quite sure how to best solve.  It involves the render order of the 
sub-pages (for example on the Person Profile page).  On occasion I've noticed 
that the sub page tabs were not rendering in their proper order, even though I 
verified that the PageUser#renderSequence values were correct in the database.  
  The issue is that the Page#subPages list no longer has an OrderBy annotation, 
which leaves the ordering of the data up to the database (hence the occasional 
inconsistency).

So, in theory, we need to put an OrderBy annotation back on the Page#subPages list - something 
along the lines of @OrderBy("members.renderSequence").   However, there is a 
limitation in JPA where you can't order a list based on properties of entities in a sublist (in 
this case trying to order on renderSequence of List<PageUser>  members).

What do you think the best approach would be to ensure the subPages are 
returned in their proper order?  One solution would be to manually sort the 
subPages List in the Page#getSubPages() getter method, but that would not be 
the most efficient.  Any better ideas?

I've been re-reading the JPA documentation and trying to to figure out another way of doing this, but unfortunately I haven't been able to come up with another way using the current page & pageUser design. One alternative I thought about could be that we update references to ParentPage and subpages in 'Page.class' and make them of type PageUser, rather than Page.

i.e. in Page.class

    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="parent_page_id")
    private PageUser parentPageUser;

@OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL, mappedBy="parentPageUser")
    @OrderBy("renderSequence")
    private List<PageUser> subPageUsers;

That way we should be able to get the subpages using the renderSequence found in the PageUser entity. The effect of this would be that anywhere else in the code where ParentPage & subpages are referenced, we would have to update the calls so they navigate through the pageUser object first.

For example...

// as is now
PageType parentPageType = page.getParentPage().getPageType()

// updated method
PageType parentPageType = page.getParentPageUser().getPage().getPageType()

However, I am unsure if this solution would be any better than just doing a sort in the Page#getSubPages() getter method as you originally suggested.

Paul


Thanks, Tony



Reply via email to