Search code examples
odatasapui5

OData with $expand doesn't work


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' ?


Solution

  • 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.