Annotation Interface SQL


@Retention(RUNTIME) @Target(METHOD) public @interface SQL
The SQL annotation is a custom annotation used to associate SQL query strings with methods or elements in your code.

When applied to a method, field, or other element, this annotation provides a convenient way to specify an SQL query that should be associated with that element.

For example, you can use this annotation to specify a SQL query for a method as follows:

 
 @SQL("SELECT * FROM users WHERE status = 'active'")
 public void getUserData() {
     // Method implementation
 }
 
 

In the context of an OracleRepository, you can use the @SQL annotation to define custom SQL queries for repository methods. Here's an example:

 
 public interface UserRepository extends OracleRepository<User, Long> {
     // Find all active users using a custom SQL query
     @SQL("SELECT * FROM users WHERE status = 'active'")
     List<User> findActiveUsers();
 }
 
 

In this example, the @SQL annotation is used to define a custom SQL query for the findActiveUsers method in an OracleRepository interface, allowing you to execute the specified SQL query when calling the repository method.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The SQL query to associate with the annotated method or element.
  • Element Details

    • value

      String value
      The SQL query to associate with the annotated method or element.
      Returns:
      The SQL query to associate with the annotated method or element.