elmarakby / odata4j

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

JPAProducer: enums not suported #133

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create an entity with an enumfield and @Enumerated(EnumType.STRING)

What is the expected output? What do you see instead?
Trying to read this filed will result in an ClassCastException in OProperties 
in line 72 when attempting to cast the enum to String.
I would like the value instead of an Exception.

a solution would be to invoke the toString() method of the value instead of 
casting.

What version of the product are you using? On what operating system?
Using Version 0.5, OS: Windows XP SP 3

Please provide any additional information below.

Original issue reported on code.google.com by tsuki.fa...@gmail.com on 31 Jan 2012 at 9:09

GoogleCodeExporter commented 9 years ago
A patch for version 0.6: Goto org.odata4j.core.OSimpleObjects.java line 27 and 
replace the 'if' statement with a single line: 

sValue = value.toString();

Original comment by emmanuel...@gmail.com on 25 Jun 2012 at 4:12

GoogleCodeExporter commented 9 years ago
The fix works for version 0.7 too. I attach the OSimpleObjects.java file for 
version 0.7 for your convenience.

Original comment by emmanuel...@gmail.com on 21 Sep 2012 at 9:41

Attachments:

GoogleCodeExporter commented 9 years ago
Bear in mind that, as exposed by the service's metadata even without the fix, 
enums are represented as strings. I also warn you that I have only tested 
reading such entities holding enums, not creating nor editing, and the fix only 
pertains to reading. I don't know whether this is enough for creating or 
editing.

Original comment by emmanuel...@gmail.com on 21 Sep 2012 at 9:49

GoogleCodeExporter commented 9 years ago
I think that the 'if' wasn't needed to begin with.
Since toString() belongs to the Object class there isn't much point in casting 
into a String object.

Original comment by noah.dr...@gmail.com on 10 Jul 2013 at 4:48

GoogleCodeExporter commented 9 years ago
Has this fix implemented and included in 0.7.0 ?

Original comment by vikram.p...@gmail.com on 26 Aug 2013 at 8:51

GoogleCodeExporter commented 9 years ago
Was not fixed in 0.7.0

Original comment by black.up...@gmail.com on 6 Sep 2013 at 9:33

GoogleCodeExporter commented 9 years ago
It is fixed in the following pull request:

https://github.com/odata4j/odata4j/pull/3

It supports both reading and writing enum fields.

Original comment by emmanuel...@gmail.com on 22 Aug 2014 at 2:36