[ 
https://issues.apache.org/jira/browse/OLINGO-706?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14614804#comment-14614804
 ] 

srikanth raghupatruni commented on OLINGO-706:
----------------------------------------------

Hi Chandan, 

Thanks for your response. Here is the problem in detail. Hope it defines the 
problem clearly

I am using the ODataJPAServiceFactory to expose my entity model as oData 
service. In my database I have got two tables which are Page and Container. 
Below is the db model 
Page                               
Id      int
name    varchar


Container
Id      int
name    varchar
title   varchar
Page_id int

There is a foreign key relation defined on container.page_id = page.id. 
However, page_id is optional in Container table and can be null. 

In the JPA class, I have defined a ManyToOne relation in Container class like 
below
@ManyToOne(optional = true)
@JoinColumn(name = "page_id",columnDefinition="integer",nullable=true)
private Page parentPage
And exposed both parent and container classes as entities via persistence.xml. 
Now If I try to do a post operation on container without providing value for 
page_id, I am getting “Metadata cannot be null” error though the record is 
getting created in the database. 
Hope it is clear now. Please let me know if you have further questions 


> Nullable is set to true for all the relations JPA
> -------------------------------------------------
>
>                 Key: OLINGO-706
>                 URL: https://issues.apache.org/jira/browse/OLINGO-706
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.3
>            Reporter: srikanth raghupatruni
>            Priority: Blocker
>
> For all the relations defined as ManyToOne, the field type is getting set as 
> not nullable. As per my data model , the foriegnkey field can be null. 
> I tried setting the below annotations but the metadata is getting generated 
> as nullable = false
> @ManyToOne(optional = true)
> @JoinColumn(name = "page",columnDefinition="integer",nullable=true)
> private Page parentPage
> here page is my database column which can be null and have a relation defined 
> with Master table Page on Column Id.
> Because of this I am unable to read, write the data by setting the page field 
> value as null
> How can I make the nullable = true



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to