-
The SQL you want should be HQL. If you use a framework, you should try not to use standard SQL
-
It is used to take out the field of type int in the return set when the data is changed to a large spike imitation sock operation: the nuclear divination is as follows.
int count = "select count(*)from user");
int count = "select count(*)from user");
-
When updating an object, you want to get it.
Insert data using read-ahead.
params);
the_last_insert_id=jdbctemplate.queryforint("select last_insert_id()");Get the ID you just inserted
The select last insert id() statement can get the auto-incremented ID of the data you just inserted!
-
1. When you arrive at an interface, usually the program writes dao as an interface, and daoimpl is its implementation, which is oriented to interface programming.
2. If you don't use getter, it's to prevent you from using the value of setter from the outside through this class (setter, getter corresponds to writing and reading), of course, you can use its value in other ways, but it's not recommended, it will destroy the encapsulation.
3. If the comment ** is returned, it is an infinite recursive error and a count(*) result is returned.
4. Braces are an array for example.
object o=new object;
string str=;
-
**Incomplete, the interface should be implemented.
public class userdaoimpl implements userdao {
Such a DAO is the interface.
2. This is data access, no need to get set alignment.
3. It's calling yourself.
4. Pass the query parameters, see the previous SQL statement, which defines two parameters.
-
: incorrect result size: expected 1, actual 0
Spring encapsulated, queryforobject goes back to the database to query a record, if there is no record that meets the query conditions, or there are multiple records that meet the conditions, an error will be reported, but the implicit expected 1, actual 0 means that no record meets the query conditions.
Expected 1 can be understood to mean that there is one and only one record that meets the criteria, and actual 0 means that there are no records that match the record.
If the actual * is > 1, then the error will also occur. (That's what this method prescribes.) )
It can be written like this, assuming a simple table, userThe fields are:
id and name
queryforint(select count(1) as c from user where id =
If the value of c is greater than 0, it can be considered that there are one or more records.