murataydogdu / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

Create entity with property type int fails #205

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create JPA entity and add one field of type int (in my example this is the 
"visibility" property.
2. Try to create one instance by sending atom post request, but don't include 
property metadata in the request. For example:
<entry xmlns="http://www.w3.org/2005/Atom" 
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" 
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <author>
    <name/>
  </author>
  <title/>
  <content type="application/xml">
    <m:properties>
      <d:name>MyDictionary</d:name>
      <d:sourcelang>English</d:sourcelang>
      <d:visibility>0</d:visibility>
      <d:targetlang>German</d:targetlang>
    </m:properties>
  </content>
</entry>
3.The following error occurs:
java.lang.IllegalArgumentException: Can not set java.lang.Integer field 
com.iandreev.myeasyvoc.entities.Dictionary.visibility to java.lang.String
    sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
    sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
    sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
    java.lang.reflect.Field.set(Field.java:657)
    org.odata4j.producer.jpa.JPAMember$FieldMember.set(JPAMember.java:137)
    org.odata4j.producer.jpa.JPAProducer.setAttribute(JPAProducer.java:482)
    org.odata4j.producer.jpa.JPAProducer.applyOProperties(JPAProducer.java:438)
    org.odata4j.producer.jpa.JPAProducer.createNewJPAEntity(JPAProducer.java:678)
    org.odata4j.producer.jpa.OEntityToJPAEntityCommand.execute(OEntityToJPAEntityCommand.java:21)
    org.odata4j.producer.jpa.Chain.execute(Chain.java:25)
    org.odata4j.producer.jpa.JPAProducer.createEntity(JPAProducer.java:304)
    org.odata4j.producer.resources.EntitiesRequestResource.createEntity(EntitiesRequestResource.java:61)

What is the expected output? What do you see instead?
The request should have succeeded. When I read the odata spec and examples, it 
seems that the property types are not required. Or am I wrong?

What version of the product are you using? On what operating system?
0.6

Please provide any additional information below.

Original issue reported on code.google.com by vanjo1...@gmail.com on 12 Aug 2012 at 8:40

GoogleCodeExporter commented 8 years ago
I tested it with version 0.7 and seems to work, at least for this scenario. I 
will try it out with more field types these days and if it works, I will close 
the issue

Original comment by vanjo1...@gmail.com on 27 Aug 2012 at 6:44

GoogleCodeExporter commented 8 years ago
Please reopen if this is still a problem.

Original comment by john.spurlock on 10 Nov 2012 at 5:39