There're my model code
@Entity
@Table(name = "jade")
public class Jade extends BaseEntity implements Serializable {
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "jade_feature",
joinColumns = { @JoinColumn(name = "jade_id", referencedColumnName = "id") },
inverseJoinColumns = { @JoinColumn(name = "feature_id", referencedColumnName = "id") })
private List<Feature> features;
}
When I save the model, the data of List weren't saved according to the List's add method.
For example:
List<Feature> features = new ArrayList<Feature>();
features.add(a);
features.add(b);
features.add(c);
Jade jade = new Jade(features);
jade.saveAndFlush();
But the database data were 【c, a, b】Like this inserted. How to deal with this problem?
You have to make use of @OrderColumn to maintain order of the List collection .
Please have a look at the docs below:
http://docs.oracle.com/javaee/6/api/javax/persistence/OrderColumn.html
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments