A, JPA annotations in common:
1, @ Entity: a class name tag in the above, as the identity of the entity class;
2, @ Table: When a table name and its mapped entity class are not the same need @Table label instructions,
Before the label and labeling @Entity used in parallel, placed in the entity class declaration statement can be written in a separate statement lines,
You can walk with declaration statement.
@Table marked common options are name, used to indicate the name of the database table.
There is also a marked @Table two options catalog and schema for the database directory or mode setting table belongs,
Usually the database name. uniqueConstraints option to set constraints, usually not be provided;
3, @ Id: represents the object identifier is provided, the primary key attribute mapping entity class identifier in the correspondence table;
4, @ GeneratedValue: Set Identifier generation strategy is often used in conjunction with @Id.
Parameters: strategy specifies the specific generation strategy:
Method 1: @GeneratedValue (strategy = GenerationType.AUTO) is the default strategy,
That can also be written as @GeneratedValue; similar to the native strategy to hibernate,
Generated depends on the underlying database.
Third, the keyword abstract methods:
1, the method naming convention:
(1) conditional attribute conditions connected by keyword.
The first letter (2) Conditions property must be capitalized.
2, named and explained the case:
(1) And - and the equivalent SQL keywords, such as findByUsernameAndPassword (String user, Striang pwd) Find a user name and password.
(2) Or - equivalent to or keyword in SQL, such as findByUsernameOrAddress (String user, String addr) Find the user name or address;
(3) Between - equivalent to between keywords in SQL, such findBySalaryBetween (int max, int min) between the query and pay the max min;
(4) LessThan - SQL equivalent of "<", such findBySalaryLessThan (int max);
(5) GreaterThan - equivalent to the SQL ">", such findBySalaryGreaterThan (int min);
(6) IsNull - equivalent to the SQL "is null", such findByUsernameIsNull ();
(7) IsNotNull - equivalent to the SQL "is not null", such findByUsernameIsNotNull ();
(8) NotNull - and IsNotNull equivalence;
(9) Like - SQL equivalent of "like", such findByUsernameLike (String user);
(10) NotLike - SQL equivalent of "not like", such findByUsernameNotLike (String user);
(11) OrderBy - equivalent to the SQL "order by", such findByUsernameOrderBySalaryAsc (String user);
(12) Not - equivalent to the SQL, such findByUsernameNot (String user); "=!"
(13) In - SQL equivalent of "in", such findByUsernameIn (Collection userList), the parameter type Collection method may be, or may be an array variable length parameter;
(14) NotIn - SQL equivalent of "not in", such findByUsernameNotIn (Collection userList), the parameter type Collection method may be, or may be an array variable length parameter;