[ 
https://issues.apache.org/jira/browse/OLINGO-1467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mahdi Ansari updated OLINGO-1467:
---------------------------------
    Description: 
I have made an OData server with Spring-boot, JPA, Hibernate and Olingo2.

There is a *{{ManyToMany}}* relationship between {{User}} and {{Role}} entities.
{code:java}
// In User entity 
@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, 
CascadeType.MERGE}) 
@JoinTable(name = "user_authority", 
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = 
"user_id")}, inverseJoinColumns = {@JoinColumn(name = "role_id", 
referencedColumnName = "role_id")}) 
private Set<Role> roles = new HashSet<>();{code}
and
{code:java}
// In Role entity 
//bi-directional many-to-many association to User 
@ManyToMany(mappedBy="roles", fetch = FetchType.LAZY) 
@JsonIgnore 
private Set<User> users = new HashSet<>();{code}
I am using Olingo {{V2.0.11}} and spring boot version {{2.3.0.RELEASE}}.

When I try to see the list of Roles in my odata endpoint I can easily do it, 
however when I try to see list of Users like:

{{}}
{code:java}
http://localhost:9090/odata.svc/UserSet{code}
{{}}

Then I get the following error:
{code:java}
<?xml version='1.0' encoding='UTF-8'?> 
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";> 
<code/> 
<message xml:lang="en">Missing message for key 
'org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.PROPERTY_VALUE_FACETS_NOT_MATCHED'!</message>
 
</error>{code}
The interesting point is if I only retrieve one User like:

{{http://localhost:9090/odata.svc/UserSet(1)?$format=json&$expand=Roles}}

Then I can see the result, even as you saw I could expand the Roles 
relationship:

 

 

 

 

I am not sure the error comes from JPA or from Olingo. Anyone else has similar 
experiences with Olingo V2 for defining ManyToMany relationship?

  was:
I have made an OData server with Spring-boot, JPA, Hibernate and Olingo2.

There is a *{{ManyToMany}}* relationship between {{User}} and {{Role}} entities.


{code:java}
// In User entity 
@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, 
CascadeType.MERGE}) 
@JoinTable(name = "user_authority", 
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = 
"user_id")}, inverseJoinColumns = {@JoinColumn(name = "role_id", 
referencedColumnName = "role_id")}) 
private Set<Role> roles = new HashSet<>();{code}
and
{code:java}
// In Role entity 
//bi-directional many-to-many association to User 
@ManyToMany(mappedBy="roles", fetch = FetchType.LAZY) 
@JsonIgnore 
private Set<User> users = new HashSet<>();{code}
I am using Olingo {{V2.0.11}} and spring boot version {{2.3.0.RELEASE}}.

When I try to see the list of Roles in my odata endpoint I can easily do it, 
however when I try to see list of Users I get the following error:
{code:java}
<?xml version='1.0' encoding='UTF-8'?> 
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";> 
<code/> 
<message xml:lang="en">Missing message for key 
'org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.PROPERTY_VALUE_FACETS_NOT_MATCHED'!</message>
 
</error>{code}
I am not sure the error comes from JPA or from Olingo. Anyone else has similar 
experiences with Olingo V2 for defining ManyToMany relationship?


> Olingo V2 makes exception on entities with ManyToMany relationships
> -------------------------------------------------------------------
>
>                 Key: OLINGO-1467
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1467
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.11
>         Environment: Spring-boot, Hibernate
>            Reporter: Mahdi Ansari
>            Priority: Major
>
> I have made an OData server with Spring-boot, JPA, Hibernate and Olingo2.
> There is a *{{ManyToMany}}* relationship between {{User}} and {{Role}} 
> entities.
> {code:java}
> // In User entity 
> @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, 
> CascadeType.MERGE}) 
> @JoinTable(name = "user_authority", 
> joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = 
> "user_id")}, inverseJoinColumns = {@JoinColumn(name = "role_id", 
> referencedColumnName = "role_id")}) 
> private Set<Role> roles = new HashSet<>();{code}
> and
> {code:java}
> // In Role entity 
> //bi-directional many-to-many association to User 
> @ManyToMany(mappedBy="roles", fetch = FetchType.LAZY) 
> @JsonIgnore 
> private Set<User> users = new HashSet<>();{code}
> I am using Olingo {{V2.0.11}} and spring boot version {{2.3.0.RELEASE}}.
> When I try to see the list of Roles in my odata endpoint I can easily do it, 
> however when I try to see list of Users like:
> {{}}
> {code:java}
> http://localhost:9090/odata.svc/UserSet{code}
> {{}}
> Then I get the following error:
> {code:java}
> <?xml version='1.0' encoding='UTF-8'?> 
> <error 
> xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";> 
> <code/> 
> <message xml:lang="en">Missing message for key 
> 'org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.PROPERTY_VALUE_FACETS_NOT_MATCHED'!</message>
>  
> </error>{code}
> The interesting point is if I only retrieve one User like:
> {{http://localhost:9090/odata.svc/UserSet(1)?$format=json&$expand=Roles}}
> Then I can see the result, even as you saw I could expand the Roles 
> relationship:
>  
>  
>  
>  
> I am not sure the error comes from JPA or from Olingo. Anyone else has 
> similar experiences with Olingo V2 for defining ManyToMany relationship?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to