Hi all,
Got a simple problem that I can't seem to get to work and I just was wondering if someone could let me know if I'm persisting the right thing. I have two classes: Store & Field. Below is an extremely cut down version of the class with the items I'm having trouble with
Code:
class Store {
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "STORE_ID", nullable = false, updatable = false)
@org.hibernate.annotations.ForeignKey(name = "FK_FIELD_STORE_ID")
@org.hibernate.annotations.IndexColumn(name = "FIELD_POSITION", nullable = false)
private List<Field> fields = new LinkedList<Field>();
// And then the rest of it
}
class Field {
// Various properties
}
Now I want to change the order of the fields related to my store so I'm doing something like below:
Code:
List<Field> results = store.getFields();
// Do something to change the order of fields
storeDAO.persist(store); // Calls a persist and flush on my entitymanager
But for some reason, the persist doesn't do anything. I could add something else in that code above like store.setName() and that will persist fine. It just doesn't change the order of the index column.
Anyone got any clue what I'm doing wrong? I can add more info if it's needed but hopefully that simple explanation will be enough.
Cheers,
Lee
Hibernate version: 3.2.6
Name and version of the database you are using: MySQL 5