All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.teiid.spring.annotations.JavaFunction Maven / Gradle / Ivy

There is a newer version: 1.7.2
Show newest version
/*
 * Copyright 2012-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.teiid.spring.annotations;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.metadata.FunctionMethod.PushDown;

/**
 * Using this annotation define User Defined Function based on the Java
 * code.
* Using this annotation, you can define a static method on a class that is * annotated with @UserDefinedFunctions, at runtime this method will be * available for execution in Teiid queries such as {@link SelectQuery}
* *
 * 
 * @UserDefinedFunctions
 * public class UserFunctions {
 *
 *   @JavaFunction
 *   public static String addHello(String value) {
 *     return "Hello "+value;
 *   }
 * }
 *
 * 
 * 
* * Then above function can be used in annotation queries such as * @SelectQuery * *
 * 
 * @Entity
 * @SelectQuery(select ssn as id, addHello(concat(firstname, concat(lastname,','))) as full_name, dob as dob FROM myTable)
 * public class Person {
 *    @Id
 *    private Long id;
 *    private String fullName;
 *    private date dob;
 * }
 * 
 * 
* * Note: functions can be used any where you are writing SQL as part of Entity * definition. For an example see * {@link org.teiid.spring.annotations.UserDefinedFunctions } * * For more information checkout UDF * in Teiid. * */ @Target(ElementType.METHOD) @Retention(RUNTIME) public @interface JavaFunction { boolean nullOnNull() default false; Determinism determinism() default Determinism.DETERMINISTIC; PushDown pushdown() default PushDown.CAN_PUSHDOWN; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy