Different database self-growth ID configuration
Can be used concurrently for different databases
@Id
@GeneratedValue (strategy = Generationtype.auto)
2 for MySQL
@Id
@GeneratedValue (strategy = generationtype.identity)
3 for Oracle
@Id
@GeneratedValue (strategy = generationtype.sequence,generator= "S_gen")
@SequenceGenerator (name= "S_gen", Sequencename= "S_seq")
No associated table Association query configuration
1, Fetchtype.lazy: Lazy loading, loading an entity, the definition of lazy loaded properties are not immediately loaded from the database. 2, Fetchtype.eager: Urgent load, when loading an entity, the properties that define the urgent load are immediately loaded from the database. 3, for example, the user class has two attributes, name and address, like Baidu know, login after the user name is required to display, this attribute is used to the odds are great, to immediately to the database to check, with the urgent load; and the user address in most cases do not need to display, only in the viewing user information is needed to display, Need to use to check the database, with lazy loading just fine. Therefore, not a login to the user's all the data loaded into the object, so there are two load modes.
Name is the Entity property that the current entity attribute referencedcolumnname is associated with
FETCH=FETCHTYPE.LAZY) Delay Loading association tables don't mess around, sometimes you need a puncture.
@ManyToOne (Targetentity=unitorganizations.class,fetch=fetchtype.lazy)
@JoinColumn (name= "org_id", referencedcolumnname= "Id", Updatable=false,insertable=false)
Public Unitorganizations getorganizations () {
return organizations;
}
It is recommended to load the "many" side of the "one" side with delay in a multiple-pair association
You can explicitly "left outer join" in HQL.
This makes hibernate less accessible to the database, or you can use "@BatchSize (size = 5)" To reduce the number of times you access the database
Hibernate Mysql Self-growth annotation configuration, table no associated annotation Mode Association query