heartin's blog

Logging in Hibernate 4.3

You have different logging options in Hibernate and let us see some of those options quickly. Hibernate supports simple property based log enabling to supporting standard logging frameworks and even programmatically accessing log statistics.

 

Hibernate Framework References

We use various materials like books, internet resources etc. for our learning, for teaching and even for preparing notes. We will list those materials here for your reference. We might include only the very basic information required for our learning and training purposes here. You may refer to these additional materials for further reading and learning.

 

Books

  • Hibernate Recipes: A Problem-Solution Approach by by Joseph Ottinger, Gary Mak and Srinivas Guruzu.

Configuring a Hibernate 4.3 Application with JPA Entity Managers

In JPA, the EntityManager controls the lifecycle of the entities.

Different ORM vendors provide its own entity manager, which is usually a wrapper around the core API and thus supports the JPA programming interfaces, life cycles and query language.

You obtain the EntityManager from an entity manager factory. EntityManagerFactory has the same role as SessionFactory in Hibernate.

Hibernate Questions on Important Differences for Self Assessment

These are some of the commonly asked questions to check if you know the differences between important concepts or APIs in Hibernate. This may contain beginner to advanced level questions.

 

  1. Differentiate between entities and value types in Hibernate.

  2. What is the difference between save() and persist() methods in Hibernate?

  3. What is the difference between get and load methods in hibernate?

Different Ways to Configure in Hibernate 4.3

Before working with hibernate in your code, you will need to configure Hibernate with information regarding your database such as host, port, credentials etc. You also need to create mappings that tell hibernate how to map the state of a Java entity to the columns of its corresponding table.

We can configure various hibernate features either through annotations or through xml files (hbm files). Preferred approach currently is annotations.

 

You can configure Hibernate mainly in three ways:

Hibernate Essentials Questions for Self Assessment

This is a list of basic questions from Hibernate which you can use to check your understanding or even prepare for interviews. You may use the parent chapter, other chapters or hibernate or the forum to discuss more on these questions.

 

  1. What is a framework?

  2. What do you mean by CRUD?

  3. What is Hibernate? What are the advantages of using Hibernate?

  4. What is Java Persistence API (JPA)?

[Problems] Summary of Problems on Arrays

  1. Find all pairs of integers within an array that sum to a specified value:

    • Approach 1: Using hash table (more time efficient)

    • Approach 2: Through sorting (more space efficient)

  2. Given an M x N matrix, if an element is 0, its entire row and column in the matrix should be set to 0.

  3. You are given a 2-Dimensional array (matrix) and a scale factor. You need to write a method to scale the 2D array according to the scale factor.

[Problems] Summary of Problems on Sorting and Searching

  1. Merge two sorted arrays A and B in sorted order. A has enough locations in the end to hold the elements of B.

    • No extra buffer should be used.

    • Every element should be shifted from its current position in A, at most 1 time.

    • Hint:

      • Start filling from the end of A.

  2. Sort an array of Strings. All anagrams should be next to each other.

    • Hint:

      • Approach 1: Modify the comparator to indicate that two anagrams are equal, and then sort.

[Problems] Summary of Problems Based on Mathematics and Probability

  1. Write methods to implement the multiply, substract and divide operations for integers, using only the add operator.

    • Hint:

      • a + b => a + negate(b)

      • a * b => add b a times

      • x = a / b => a = bx.

  2. Find the kth number such that the only prime factors are 3,5 and 7

[Algorithm+Implementation] Sieve of Eratosthenes Algorithm for Finding all Prime Numbers Up To Any Given Limit

In mathematics, the sieve of Eratosthenes is an algorithm for finding all prime numbers up to any given limit.

It does so by iteratively marking as composite (i.e., not prime) the multiples of each prime, starting with the multiples of 2.

It works on the principle that all non-prime numbers are divisible by a prime number.

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!