Two, java framework for learning

Two, java framework for learning

  • Writing rules entity classes
    • Physical properties of the class are private
    • private attributes using the disclosed set, get, a method of operating
    • It requires a unique entity class has attribute value (id value is generally used)
    • Entity class attribute is not recommended basic data types, corresponding to the basic data types used packaging,
      eight basic data types corresponding packaging
      • int--Integer
      • char--Character
      • Other initial capital letters Example: double - Double
      • Expressed as a fraction of students is 0: int score = 0; but not accurately indicate whether students take the exam.
        If you use the wrapper classes can be: Integer = 0 score 0, Integer = null did not take the exam.
  • Hibernate primary key generation strategy
    • Hibernate claim entity class which has a property as a unique value, the corresponding primary key, the master key generation strategy may be different.
    • Hibernate primary key generation strategy has a lot of value


  • There are many in the class attribute value.
    native: Depending on the database used to select which value to use
    uuid: hibernate help generate uuid
  • Uuid generation strategy used, the type of entity class id attribute must be a string type.
  • (Some specific operation and demonstration slightly)
  • Hibernate's cache
    • Hibernate framework provides a lot of optimization ways, its cache optimization is a way
    • Hibernate caching features
      • By default
      • Range is created from session to session close range
      • Stored data must be persistent state data
  • Hibernate secondary cache
    • You need to configure
    • Range is sessionFactory
  • Hibernate transaction code written specification
    • Code structure
      try {open transaction
      commit the transaction
      } catch () {roll back the transaction
      } finally {
      Close
      }
  • Binding Hibernate session
    • Gets the local thread sessio, hibernate core configuration in the configuration file
    • SessionFactory inside the method call


Guess you like

Origin www.cnblogs.com/zaw-315/p/11260711.html