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

Chandan V.A commented on OLINGO-329:
------------------------------------

Hi Rudy,
You could try this.
1) Create a Class by implementing javax.persistence.AttributeConverter as shown 
below. The class should be annotated with javax.persistence.Converter.

@Converter(autoApply = true)
public class BigIntegerToIntConverter implements AttributeConverter<Integer, 
BigInteger> {
  @Override
  public BigInteger convertToDatabaseColumn(Integer arg0) {
    return BigInteger.valueOf(arg0.intValue());
  }
  @Override
  public Integer convertToEntityAttribute(BigInteger arg0) {
    return Integer.valueOf(arg0.intValue());
  }
}

2) In the JPA Entity class create a property with type as Integer and annotate 
the same with javax.persistence.Convert annotation.
example -   
@Column(name = "MEASUREMENT")
 @Convert(converter = 
org.apache.olingo.odata2.jpa.processor.ref.converter.BigIntegerToIntConverter.class)
  private Integer measurement;

The converter class takes care of converting the Integer type to BigInteger 
type which the underlying Database understands.

I hope this solves the problem. There are many articles over the Internet that 
talks about how to use Converters in JPA 2.1

Thanks
Kind Regards
Chandan

> Not all JPA data types handled correctly
> ----------------------------------------
>
>                 Key: OLINGO-329
>                 URL: https://issues.apache.org/jira/browse/OLINGO-329
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 1.2.0
>            Reporter: Rudy Gardelein
>            Assignee: Chandan V.A
>             Fix For: V2 2.0.1
>
>
> As described in the following link 
> (http://scn.sap.com/community/gateway/blog/2014/02/05/odata-producer-using-apache-olingo-with-mysql-jpa-tomcat-web-server)
>   there are issues with the correct translation of JPA data types boolean and 
> timestamp in version V2 1.2 of Olingo.
> Boolean datatype is translated to Java byte type.  Timestamp is translated to 
> Java timestamp.  Both of these however do not work in the Odata service as 
> generated by Olingo.
> Raising this issue as suggested by Chandan V.A. from SAP.



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

Reply via email to