Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Olingo Wiki" for change 
notification.

The "ojp-handling-blob-proposal" page has been changed by chandanva:
https://wiki.apache.org/Olingo/ojp-handling-blob-proposal

New page:
=== Handling Blob and Clob data types ===
==== Overview ====
JPA Entities can have properties that are typed as '''java.sql.Blob''' or 
'''java.sql.Clob'''. Internally JPA entities can instantiate a JPA provider 
(Eclipse Link or Hibernate or ...) specific implementation of the above two 
interfaces and bind them to the properties. Now to enable write on such 
properties using OData JPA processor an additional access modifier is required 
to be added to the JPA entities. Following is the proposal on how OData JPA 
processor handles java.sql.Blob and java.sql.Clob during meta data generation 
and run time processing.

==== EDM generation ====
Following is the pseudo code for generating the EDM when the JPA entity 
property is typed as '''java.sql.Blob'''

  '''Step 1''' - Check if JPA entity property is of type  byte[] or ( of type 
java.sql.Blob and annotated with @Lob annotation ).

  '''Step 2''' - If Step 1 is true then generate an EDM property with type as 
Edm.Binary

In case of '''java.sql.Clob'''
  '''Step 1''' - Check if JPA entity property is of type java.sql.Clob and 
annotated with @Lob annotation.

  '''Step 2''' - If Step 1 is true then generate an EDM property with type as 
Edm.String with no max length unless a max length is specified.

==== Run time Processing ====
Following is the pseudo code for handling the '''java.sql.Blob''' during run 
time

Before discussing the pseudo code, it is mandatory to add an additional access 
modifier to the JPA entity that takes in a byte array as parameter. 

Example
{{{
public void setBlob(Blob blob) {
  this.blob = blob;
}

public void setBlob(byte[] b) {
  this.blob = new <Provider Specific Blob implementation>(b);
}

}}}


  '''Step 1''' - Check if the JPA entity property is of type java.sql.Blob.

  '''Step 2''' - If Step 1 is true then invoke the method setBlob(byte[].class).

  '''Step 3''' - If method setBlob(byte[].class) is not defined throw exception.

Step 3 is needed because the OData library is not bound to any specific 
implementation of Blob interface.

In case of '''java.sql.Clob''' it is mandatory that an additional access 
modifier with character array as parameter should be defined.

Example:
{{{
public void setClob(Clob clob) {
  this.clob = clob;
}

public void setClob(char[] c) {
  this.clob = new <Provider Specific Clob implementation>(c);
}

}}}

The pseudo code for setting value for type java.sql.Clob is similar to that of 
java.sql.Blob.

Reply via email to