(Play framework) Setting initial data yaml on an @OrderColumn

时间:2016-04-07 10:40:15

标签: java jpa playframework

I can't seem to get the data to populate the ordering column on a play bootstrap with my initial-data yaml file. It just shows as null values on the column it creates named "entries_ORDER".

In my yaml file I have tried 'entries: 0' and 'entries_ORDER: 0' with no luck.

Group.java

public class ContactGroup extends Model {
    @Required
    public String title;

    public boolean showTitle = false;

    public boolean isDefault = false;

    @OneToMany(mappedBy="group", cascade=CascadeType.ALL, orphanRemoval=true)
    @OrderColumn
    public List<ContactEntry> entries;
}

initial-data.yml

# Contact Group
ContactGroup(group1):
    isDefault: 1
    showTitle: 1
    title: My Title

# Contact Entry
ContactEntry(entry1):
    title: Entry Title 1
    group: [group1]
    entries_ORDER: 0

ContactEntry(entry2):
    title: Entry Title 2
    group: [group1]
    entries_ORDER: 1

1 个答案:

答案 0 :(得分:0)

我设法让它发挥作用。

我不得不告诉@OrderColumn使用我设置的字段,而不是让它自己创建列。

我在ContactEntry模型上创建了以下内容:

public Integer entries_order;

然后在我的ContactGroup模型中为@OrderColumn提供了该Integer的名称:

@OrderColumn(name="entries_order")

然后我只能用我的yaml:

entries_order: 3