2
votes

I try to use $expand parameter in view xml but combobox doesn't display data

enter image description here

        <Text text="ID_PLANNING"/>
        <ComboBox items="{path :'/T027_03s', parameters:{expand : 'T027Details'}}">
            <core:Item text="{T027Details/BEG_DATETIME}"/>
        </ComboBox>

When $expand T027Details from T027_03s table, the link ..../T027_03s?$expand=T027Details

enter image description here

Here is $metadata for T027_03 table with navigation property: T027Details

enter image description here

Here is my code of creation entity in Java

@Entity public class T027_03 implements Serializable {

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_T027_03")  
private Long ID_PERSONNEL_PLANNING;
private Integer ID_PERSONNEL;
private Long ID_PLANNING;
private static final long serialVersionUID = 1L;
[...]
@ManyToOne
@PrimaryKeyJoinColumn(name="ID_PLANNING")
private T027 T027;

public T027 getT027() {
    return this.T027;
}
public void setT027(T027 T027) {
    this.T027 = T027;
}
[...]
} 

And in classe T027

@Entity public class T027 implements Serializable {

@Id 
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_T027")
private Long ID_PLANNING;
private Timestamp BEG_DATETIME;
[...]
private static final long serialVersionUID = 1L;

@OneToMany(mappedBy="T027")
private List<T027_03> T027_03S;

public List<T027_03> getT027_03S() {
    return this.T027_03S;
}
public void setT027_03S(List<T027_03> T027_03S) {
    this.T027_03S = T027_03S;
}

I have seen the same question OData Model Not Working but I don't know how to resolve it. Their reponse is to add "RESULT".. . but how I can add 'RESULT' ?

4

4 Answers

1
votes

Try adding parent entity name in combo box item key and text

<core:Item key="{T027_03s/T027Details/ID_PLANNING}" text="{T027_03s/T027Details/ID_PLANNING}"/>
1
votes

You should bind a node with multiplicity more than 1 in your "items" aggregation. The expand just retrieve more data in your request. But there is still 1 item only.

To fix it, do elementBinding of your node "T027_03s" and then aggregationBinding with your "T027Details" like the following:

<ComboBox binding="{path:'/T027_03s', parameters:'expand:T027Details'}" items="{T027Details}">
    <core:Item text="{ID_PLANNING}" key="{ID_PLANNING}"></core:Item>
</ComboBox>
1
votes

Looks like you are trying to access a property (ID_PLANNING) of the T027_03s entity type.

If you bind your ComboBox items to look like:

<ComboBox items="{path :'/T027_03s', parameters:{expand : 'T027Details'}}">
    <core:Item key="{ID_PLANNING}" text="{ID_PLANNING}"/>
</ComboBox>

You should see results from the T027_03s entity set

But... If you are looking to display a property on T027Details, your binding syntax looks like it should work so long as you are binding a valid property of the T027Details entity type.

In other words, if you wanted to display a valid property DETAIL_PROPERTY that is part of the T027Details entity set for each entry in T027_03s, you would do it like:

<ComboBox items="{path :'/T027_03s', parameters:{expand : 'T027Details'}}">
    <core:Item key="{T027Details/DETAIL_PROPERTY}" text="{T027Details/DETAIL_PROPERTY}"/>
</ComboBox>
1
votes

My solution has been sovled for now. I've added @Cache(isolation=CacheIsolationType.ISOLATED) to T027 table

import org.eclipse.persistence.annotations.Cache;
import org.eclipse.persistence.config.CacheIsolationType;

@Id 
@Cache(isolation=CacheIsolationType.ISOLATED)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_T027")
private Long ID_PLANNING;
private Timestamp BEG_DATETIME;
[...]
private static final long serialVersionUID = 1L;

@OneToMany(mappedBy="T027",cascade =CascadeType.ALL, fetch = FetchType.EAGER)
private List<T027_03> T027_03S;

Here is the solution I found

Regards.