Skip to content

How to implement user defined function using eclipselink ? #242

@suraj-mane-zellis

Description

@suraj-mane-zellis

As suggested in issue - #238 . I have exclude hibernate and use eclipse library for jpa implementation . We had implement custom function which supported in hibernate and how we can implement same in eclipse link

Implementation with Hibernate :

      import org.hibernate.boot.MetadataBuilder;
      import org.hibernate.dialect.function.SQLFunctionTemplate;
      import org.hibernate.type.StandardBasicTypes;

  public class TestMetadataBuilderContributor {

  public static void commonSqlFunctions(MetadataBuilder metadataBuilder) {
    metadataBuilder.applySqlFunction("cast_as_time", new SQLFunctionTemplate(StandardBasicTypes.TIME,
            "cast(?1 as time)"));
    metadataBuilder.applySqlFunction("cast_as_date", new SQLFunctionTemplate(StandardBasicTypes.DATE,
            "cast(?1 as date)"));
    
             }
         }

olingo-jpa-processor-v4 - Custom implementation in JPAOperationConverter.class

 case DATE:
  
  return cb.function("cast_as_date", Date.class, (Expression<Timestamp>) jpaFunction.getParameter(0).get());

I have gone through eclipse link official document , I have found something .

https://wiki.eclipse.org/Introduction_to_EclipseLink_Expressions_(ELUG)#Creating_and_Using_a_User-Defined_Function

Can you please provide how we can implement database specific custom function in jpa processor side using eclipse link?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions