Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:13:21+00:00 2026-05-30T00:13:21+00:00

I am using Hibernate’s @OrderColumn annotation to order a list in my database. It

  • 0

I am using Hibernate’s @OrderColumn annotation to order a list in my database. It correctly generates the column in the database table to store index and also stores the correct index initially.

But when I try to change the ordering in the list and then use Spring Roo’s merge() method to update the database, the ordering doesn’t change.

Here is the code for my entity:

@RooJavaBean
@RooToString
@RooEntity
public class Story {

    @ManyToMany(cascade = CascadeType.ALL)
    @OrderColumn
    private List<Slide> slides = new ArrayList<Slide>();

    @ManyToOne
    private Question question;

    private String title;

}

Here is the update method which calls merge function:

@RequestMapping(method = RequestMethod.PUT)
public String StoryController.update(@Valid Story story, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("story", story);
        return "storys/update";
    }
    uiModel.asMap().clear();
    story.merge();
    return "redirect:/storys/" + encodeUrlPathSegment(story.getId().toString(), httpServletRequest);
}

I have checked using debugging that the story object has the updated indices in the slides list.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:13:22+00:00Added an answer on May 30, 2026 at 12:13 am

    When you say:

    It correctly generates the column in the database table to store index and also stores the correct index initially.

    Are you sure about that? When I created a sample project with hibernate mapping similar to your Stories and Slides nothing was being inserted into the intermediary table. Make sure your join table between stories and slides is being populated at all. You can add

    log4j.logger.org.hibernate.SQL=DEBUG
    

    to log4j.properties and inspect the log.

    I had to add an explicit @JoinTable to the association so that all operations were cascaded correctly.

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable
    @OrderColumn
    private List<Slide> slides = new ArrayList<Slide>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using hibernate, how can I persist a class with a List<String> field? Consider the
I am using Hibernate in a Java application to access my Database and it
I'm using Hibernate for ORM of my Java app to an Oracle database (not
I am using Hibernate 4 and would like to simply list all rows of
I'm using Hibernate to store a data model, which has a number of simple
I am using hibernate and have bi-directional relations. How should I correctly override equals()
I'm using hibernate to store a set of objects from a web service. As
Using hibernate ctiteria I want to select an object and it's associated oneToMany list
I am using Hibernate 3.0 in my application with Postgres database. It is a
I am using Hibernate JPA and Spring with a Mysql database and I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.