JPA Examples

This section will describe you the various examples that will help you create JPA applications. In this page you will find various examples like methods of JPA query methods example, example for executing queries, JPQL aggregate functions, JPQL functions, using Eclipse IDE to develop and compile the examples.

JPA Examples

JPA Examples

In this section we will discuss about the examples of JPA.

This section will describe you the various examples that will help you create JPA applications. In this page you will find various examples like methods of JPA query methods example, example for executing queries, JPQL aggregate functions, JPQL functions, using Eclipse IDE to develop and compile the examples.

Here I am giving a list of examples that helps you to create JPA applications.

  • JPA query methods : Here you will find the examples of methods used in Query.
     
    • setFirstResult() : This method skips the number of elements specified in the parameter of this method and then returns the result from the specified number of rows.
    • setMaxResults() : This method limits the maximum number of results returned from the database.
    • getResultList() : This method is used to find the list of results.
    • getSingleResult() : This method is used to find the single result from query result.
    • executeUpdate() : This method is used to execute update and/or delete query.
       
  • JPA-QL Queries : Here you will find the examples that will help you how to execute queries in JPA.
     
  • JPA Native Queries : Here you will find the examples which will demonstrate you how to execute Native queries in JPA.
     
  • JPA Named Query : Here you will read about the JPA Named query and its types as well as how to use JPA named query in your application.
     
  • JPA Named Parameter : Here you will read about why JPA Named Parameter is used and how to use Named Parameter in your application.
     
  • JPA Ordering : Here you will read about how to get your result in a specific order i.e. in ascending order or descending order.
     
  • JPA Grouping : Here you will read about how to get you result in a specific group.
     
  • JPA Sub-Queries : Here you will read about using of sub-queries in your JPA application.
     
  • JPQL Aggregate Functions
     
    • avg() : This method returns an average of given numbers.
       
    • sum() : This method returns the sum of given numbers.
       
    • min() : This method returns the minimum value from the given list.
       
    • max() : This method returns the maximum value from the given list.
       
    • count() : This method counts the records of database table.
  • JPQL Functions
    • concat() : This method is used to concatenate the two strings or literals.
       
    • substring() : This method is used to find a new string from the given string. The new string is the part of the given string.
       
    • trim() : This method is used to remove the additional spaces from the given string.
       
    • lower() : This method is used to convert the characters written in upper case into lower case.
       
    • upper() : This method is used to convert the characters written in lower case into upper case.
       
    • length() : This method is used to get the length of the string.
       
    • locate() : This method is used to find out the index of search string in the specified string.
       
    • abs() : This method is used to find out the absolute value of the given field.
       
    • sqrt() : This method is used to find out the square root of the given number.
       
    • mod() : This method is used to find out the modulus of the given number.
       
  • JPA Relationships Example : In this section you will read about how to persist relative data.
     
    • One-to-one : In this section you will read about how to map one-to-one relationship in JPA.
       
    • One-to-many : In this section you will read about how to map one-to-many relationship in JPA.
       
    • Many-to-one : In this section you will read about how to map many-to-one relationship in JPA.
       
    • Many-to-many : In this section you will read about how to map many-to-many relationship in JPA.
       
    • Many-to-many Retrieve data : In this section you will read about how to retrieve data from database table using JPA many-to-many relation.
       
  • Some miscellaneous examples
     

For more examples please go through the link http://www.roseindia.net/jpa/index.shtml.