anchor.diff:    - no argument constructor
     - getter and setter for all interested fields
     - 
  -
  -:source-highlighter: coderay
  -
  -[source,java]
  -----
  -System.out.println("test code");
  -----
  -
  -
  -
  -
  +  
  +Providing an ID for Persistence
  +
  + ID element has attributes such as column, type, and generator that you use to generate the identifier.
  + 
  +•	 Database sequence
  +•	 Native generator
  +•	 Increment generator
  +•	 Hilo generator
  +
  +Some of these strategies are available only for specified databases; for instance, the sequence strategy is
  +not supported in MYSQL, but it is provided by Oracle.
  +
  +Sequence:
  +[source,java]
  +----
  +@Id  @GeneratedValue(strategy = GenerationType.SEQUENCE)
  +public Long id;
  +----
  +
  +Enhanced Sequence Style Generator
  +
  +Optimization allows you to query a bunch of identifiers at a time and store them in local memory.
  +Once they have been exhausted, the database can be queried for the next group of identifiers, which avoids
  +making a call to the database for every new identifier.
  +Use the GenericGenerator tag for these enhanced generators:
  + 
  +[source,java]
  +----
  +@GeneratedValue( generator="IdGen")
  +@GenericGenerator(strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",name="IdGen",
  +parameters = {
  +@Parameter(name = "sequence_name", value = "seq_id_gen"),
  +@Parameter(name = "optimizer", value = "pooled"),
  +@Parameter(name = "initial_value", value = "1000"),
  +@Parameter(name = "increment_size", value = "10")
  +})
  +----
  +
  +The initial value is set to 1000 and the increment size is 10. The optimizer
  +values can be one of the following:
  +•	 none does not perform any optimizations and hits the database for every new
  +identifier
  +•	 hilo generates the identifiers according to the hi/lo algorithm
  +•	 pooled stores the high value in the series as the nextval
  +•	 pooled-lo stores the low value in the series as the nextval
  +
  +
  +[source,java]
  +---- 
  +@Id
  +@GeneratedValue( generator="IdGen")
  +@GenericGenerator(strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",name="IdGen",
  +parameters = {
  +@Parameter(name = "sequence_name", value = "seq_id_gen"),
  +@Parameter(name = "optimizer", value = "pooled"),
  +@Parameter(name = "initial_value", value = "1000"),
  +@Parameter(name = "increment_size", value = "10")
  +})
  +----
  +
  +
  +
  +Increment reads the maximum primary key column value from the table and increments the value by one.
  +[source,java]
  +----
  +@Id  @GeneratedValue(generator = "increment")
  +public Long id;
  +----   
  +   
  +Hilo Generator uses the hi/lo algorithm to generate the identifiers that are unique to a particular database.
  +It retrieves the high value from a global source (by default, the hibernate_unique_key table and next_hi
  +column), and the low value from a local source. The max_lo value option is provided to define how many low
  +values are added before a high value is fetched
  +[source,java]
  +----
  +@Id
  +@GeneratedValue(generator = "hilo")
  +public Long id;
  +----
  +
  +The hilo generator is of type long. This generator should not be used with a user-supplied connection.
  +The high value must be fetched in a separate transaction from the Session transaction, so the generator must
  +be able to obtain a new connection and commit it. Hence, this implementation cannot be used when the user
  +is supplying connections. In that case, a SequenceHiLoGenerator is a better choice (where supported).
  +The hilo generator is used for batch operations
  +
  +
  +Enhanced Table Generator
  +This generator defines a table that holds the increment values, and the same table can be used by multiple
  +applications for the increment values. Each application is distinguished by the key value.
  +[source,java]
  +----
  +@GeneratedValue( generator="TableIdGen")
  +@GenericGenerator(strategy="org.hibernate.id.enhanced.TableGenerator",name="TableIdGen",
  +parameters = {
  +@Parameter(name = "table_name", value = "enhanced_hibernate_sequences"),
  +@Parameter(name = "segment_value", value = "id"),
  +@Parameter(name = "optimizer", value = "pooled"),
  +@Parameter(name = "initial_value", value = "1000"),
  +@Parameter(name = "increment_size", value = "10")
  +})
  +----
  +
  +Creating a Composite Key
  + 
  +[source,java]
  +----
  +public class EmployeeId implements Serializable {
  +Long department;
  +Long idCard;
  +
  + 
  +@Entity
  +@IdClass(EmployeeId.class)
  +public class Employee {
  +@Id
  +Long department;
  +@Id
  +Long idCard;
  +----
  +
  +
  +Composite ID as a Property Using a Component Type
  +[source,java]
  +----
  +@Embeddable
  +public class ISBN implements Serializable {
  +@Column(name = "group_number")
  +int group;
  +int publisher;
  +int titleRef;
  +int checkDigit;
  +}
  +
  +
  +@Entity
  +public class Book {
  +@Id
  +ISBN id;
  +@Column
  +String title;
  +----
  +
  +== O mnie
  +* programista
  +* blog link:http://przewidywalna-java.blogspot.com[]
  +* image:{image-link} [role='img-circle']
  +
  +
  +
  
positive.code: = Jpa and spring data kata
  
  #Sample demo to show how jpa work in effiecient way
  
  
negative.code:      - OGM - support for NoSql database operation. Reusing Hibernate core engine to persistence and mapping nosql data.
       - Envers - audit logging and keeping multiple version. Allow to show history operation is also similar to version control system like svn or git
    
  * Hibernate benefits:
      - Productivity -> (metadate, query data, decrease development time -> productivity increase )
      - Prototyping  -> extremely useful for quick prototyping
      - Maintainability
      - Vendor independence
      
  * Hibernate disadventage
     - Learning curve
     - Overhead
     - Slower performance: For large batch updates, performance is slower.
     
     
  * SessionFactory
  * Opening and Closing Sessions
    represents a unit of work and is bound to the current thread
    It also represents a
   transaction in a database. A session begins when getCurrentSession() is first called on the current thread.
   The Session object is then bound to the current thread. When the transaction ends with a commit or
   rollback, Hibernate unbinds the session from the thread and closes it.   
   :source-highlighter: coderay
   [source,java]
  ----
   Session session = factory.openSession();
  try {
  // Using the session to retrieve objects
  }catch(Exception e)
  {
  e.printStackTrace();
  } finally {
  session.close();
  }
  ----
   
  Retrieving and Persisting Objects
  Book book = (Book) session.load(Book.class, isbn);    
    when the given ID can’t be found, the load() method throws an org.hibernate.ObjectNotFoundException exception
    he load() method just returns a proxy by default; the database  isn’t hit until the proxy is first invoked
    
  Book book = (Book) session.get(Book.class, isbn);
     get() method returns a null object
     get() method hits the database immediately
     
  The load() method is useful when you need only a proxy, not’ a database call. You need only a proxy in a given session  when you have to associate an entity before persisting.   
        
  * Using the JPA EntityManager
   [source,groovy]
  ----
  <dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-entitymanager</artifactId>
  <version>4.3.5.Final</version>
  </dependency>
  ----
  
  EntityManagerFactory has the same role as SessionFactory in Hibernate. It acts a factory class that
  provides the EntityManager class to the application.
  
  
  JTA is used in J2EE-managed applications in which the container is responsible for  transaction propagation.
  For application-managed transactions, you can use RESOURCE_LOCAL.
  
  
  Enabling Logging in Hibernate
  Inspecting the SQL Statements Issued by Hibernate <property name="show_sql">true</property>
  Enabling Live Statistics  <property name="hibernate.generate_statistics">true</property>      
        
  * Problem of subtypes
  
  * Simple entity
  