0

I looked into the documentation (hibernate 4.1) . And I'm kind of confuse, I wish to be able to use the annotation @OrderColumn(name="orders_index") in my set Collection (for design purpose). Right now, I'm actually adding manually a orders_index manually in my PersonnalTaskMacro but it's getting a pain in the * (I need to refactor that...). I came accross the @MapKeyColumn(name="orders_number"), but it's not really what I want. How can I achieve this?

@Entity
@Table(name = "PERS_TASK_MACRO_PARAMETER")
public class PersonnalTaskMacroParameter extends Parameter {

    /* .... */

    @OneToMany(cascade = { CascadeType.ALL } , fetch = FetchType.LAZY)
    @JoinTable(name = "PERS_TASK_MACRO_JOIN", 
    joinColumns = { @JoinColumn(name = "MODULE_PARAMETER_ID") }, 
    inverseJoinColumns = { @JoinColumn(name = "PERS_TASK_MACRO_ID") })
    @ForeignKey(name="FK_PERS_TASK_MACRO_PARAM_ID", inverseName="FK_PERS_TASK_MACRO_ID")
    private Set<PersonnalTaskMacro> personnalTaskMacroSet = new HashSet<PersonnalTaskMacro>();

/* .... */
}

1 Answer 1

1

A Set is not an ordered collection. The documentation you cited points in the right direction: change

Set<PersonnalTaskMacro> personnalTaskMacroSet ...

to

List<PersonnalTaskMacro> personnalTaskMacros ...

You can also use SortedSets to do something similar, but that depends on the sort key being part of the entity that you have a collection of.

Sign up to request clarification or add additional context in comments.

1 Comment

Happy to help. If you're all set, you should accept the answer, using the green check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.