问题
Would be really interesting if the expand system query option works for any of you when using this library version.
Library and Frameworks combination: Java OData 2 JPA Library 2.0.11 + JPA Hibernate + MySQL
I am trying to use the system query option "expand" (eg. /books?$expand=PublisherDetails) in an OData query. At UriParserImpl#handleSystemQueryOptionExpand - L#796 occurs a NPE cause the edmType of the fetched property at L#792 is null
If i want to query data from another table using recursive queries (eg. books('id')/PublisherDetails) i am running into the same problem in a different way. UriParserImpl#handleNavigationProperties - L#299
UriParserImpl java class in library: https://github.com/apache/olingo-odata2/blob/master/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/UriParserImpl.java
Persistence Entities:
Book
@Entity(name = "book")
public class Book implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(length = 100)
protected String bookID;
.
.
.
@ManyToOne(cascade = { CascadeType.REFRESH })
private Publisher publisher;
public String getBookID() {
return bookID;
}
public void setBookID(final String bookID) {
this.bookID= bookID;
}
public Publisher getPublisher() {
return publisher;
}
public void setPublisher(final Publisher publisher) {
this.publisher = publisher;
}
.
.
.
}
Publisher
@Entity(name = "publisher")
public class Publisher implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(length = 100)
private String id;
.
.
.
@OneToMany(fetch = FetchType.LAZY, mappedBy = "publisher")
private List<Book> books;
public String getId() {
return id;
}
public void setId(final String id) {
this.id = id;
}
.
.
.
}
My Navigation Properties and Associations would look fine when fetching it via $metadata..
Navigation Property:
<NavigationProperty Name="PublisherDetails" Relationship="persistence-unit-name.book_Publisher_Many_ZeroToOne0" FromRole="book" ToRole="Publisher"/>
Association:
<Association Name="book_Publisher_Many_ZeroToOne0">
<End Type="persistence-unit-name.book" Multiplicity="*" Role="book"/>
<End Type="persistence-unit-name.Publisher" Multiplicity="0..1" Role="Publisher"/>
EntityContainer:
<EntityContainer Name="persistence-unit-nameContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="books" EntityType="persistence-unit-name.book"/>
<EntitySet Name="publishers" EntityType="persistence-unit-name.publisher"/></EntityContainer>
And... is it normal that i don't have foreign key Properties in my EntitySets?
Tips on what i might be doing wrong are much appreciated.
来源:https://stackoverflow.com/questions/61821485/expand-not-working-in-my-jpa-olingo-2-0-11-odata-service