1 , basic query
1, non-conditional query
2. Query with conditions
3, through the parameters of the query
4. Query by named parameters
5. Querying empty elements
2 , common query
1. List query (in ())
2. Projection Query
3, projection of an element query ( NOTE: You cannot use SELECT * to query )
4. Other types of projection
5. Single element query (Uniqueresult)
6, paging query
3 , Object-based queries, and SQL Native Query
There is also an object-based query in hibernate
Queries can be queried directly using SQL statements in Hibernate (occasionally used)
4 , connection query
4.1. SQL-based queries
Three ways to connect
1, internal connection (the two tables connected to have data connection)
SELECT * from t_student T1 JOIN t_classroom T2 on (t1.cla_id=t2.id)
The above data are data in both T_student and T_classroom.
2. Left Outer connection
SELECT * from T_classroom T1 left joins T_student T2 on (t2.cla_id=t1.id)
The result above is all the data on the left side of this table to connect to the data on the right table, if the right table has no data, it will be filled directly with NULL, which is very useful when doing statistics
3. Right outer connection
SELECT * from T_classroom T1 right JOIN t_student T2 on (t2.cla_id=t1.id)
The above is all the data from the right table, and if left table not, use NULL to populate
4.2, Hibernate-based connection query
1, using the object navigation link (a more convenient way of operation) limitation: only the internal connection
2, using the connection operation mode
3. Use left connection (exactly the same as SQL)
4. Use Right connection
4, HQL