I have my own table, and I add manytoone relationship to cuba.security.entity.Group.
@Lookup(type = LookupType.SCREEN)
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "GROUP_ID")
protected Group group;
public void setGroup(Group group) {
this.group = group;
}
public Group getGroup() {
return group;
}
And in my webview code, I use pickerfield to select Group:
<pickerField id="code_group" metaClass="sec$Group"/>
And i have my own code to save it to database:
PickerField codeGroup = (PickerField) editBox.getComponent(CODE_GROUP);
Group group = codeGroup.getValue();
editedItem.setGroup(group);
It works and datasaved, I can edit this row successfully in entityInspector.browse page.
But while I try to edit it in my own code, it raise error: Cannot get unfetched attribute [group] from detached object.
I searched other topic, seems it related with view “_local”, but my page using view I created:
<view class="cn.com.dataocean.cip.entity.ExcelTable"
extends="_local"
name="excelTable-view"
systemProperties="true"/>
how to solve it?
The error detail is:
java.lang.IllegalStateException: Cannot get unfetched attribute [group] from detached object cn.com.dataocean.cip.entity.ExcelTable-63aa7dfe-5175-9976-9542-e880e8824968 [detached].
at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:98)
at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:61)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:2846)
at com.haulmont.chile.core.model.impl.AbstractInstance._persistence_checkFetched(AbstractInstance.java)
at cn.com.dataocean.cip.entity.ExcelTable._persistence_get_group(ExcelTable.java)
at cn.com.dataocean.cip.entity.ExcelTable.getGroup(ExcelTable.java:102)