Ask Hibernate about your update history!

Updated on technology 2024-04-18
5 answers
  1. Anonymous users2024-02-08

    Firstload();

    And then .update();

    He doesn't care who you're going to change, because hibernate is manipulating objects directly, not database records, so who you're going to change, you're going to tell him about the record, so load or get so he knows which record you're going to do with.

  2. Anonymous users2024-02-07

    First of all, you should provide an entity identifier that corresponds to the primary key in the relational database, see that your program seems to be running under c s, in addition, you also need to provide those corresponding fields in the database that cannot be empty, that is, you need to set the corresponding properties of this entity object, and then update.

  3. Anonymous users2024-02-06

    The idea is that if you find this record first, then in Hibernate the record is an object, so you find this object first and then update it

  4. Anonymous users2024-02-05

    It is better to load the value in the assignment first:

    hql = "from user as u set ? where ?"

    setparameter(0,setparameter(1,executeupdate();

  5. Anonymous users2024-02-04

    First of all, understand what Hibernate does:

    1. It is to store the things of the object model (entity class) in the relational model, 2. The class in the entity corresponds to a table in the relational library, 3. An attribute in the entity class corresponds to a column in the relational database table.

    4. An instance of the entity class corresponds to a record in a relational database table.

    Critical: %%Save object data to the database, read database data into the object

    Secondly, understand the reason why Hibernate exists:

    1. Solve the problem of impedance mismatch;

    2. There is no complete object-oriented database (all of them are relational databases);

    3. JDBC operation database is very cumbersome.

    4. SQL statement writing is not object-oriented.

    5. Associationss can be established between objects and relational tables to simplify programming.

    Finally know the scope of use of hibernate:

    1.For a certain object, it is more appropriate to simply load and modify it, and the modification is only for a single object (rather than modifying it in batches);

    2.There is a clear relationship between objects (e.g., multiple users belong to a group (many-to-one), a group has multiple users (one-to-many));

    3.Clustering operations: Hibernate is not suitable for batch addition and modification (o mapping frameworks are not suitable for use);

    4.It is not suitable for use when specific functions in the database are required, because Hibernate does not use SQL statements;

    As for what you said, then the mapping files, those are all dead, you just got started, it feels difficult, and when you write more, you will find that those things are basically fixed patterns, and you won't check them.

Related questions
5 answers2024-04-18

Hibernate application caching: Because the application accesses the database, the cost of reading and writing data is very high, and the use of persistence layer caching can reduce the interaction between the application and the database, that is, the accessed data is saved in the cache, and the application accesses the accessed data again, and the data can be obtained from the cache instead of the database. >>>More

8 answers2024-04-18

Of course, there are three to write, and one user can borrow, reserve, and handle three different borrows at the same time. How can you save three pieces of information without three! >>>More

20 answers2024-04-18

The pole five strokes are the best five strokes I have come across. (There is no one). But in win10, it often doesn't work properly. >>>More

3 answers2024-04-18

First: Custom deletion (i.e., delete which history you want to delete) In the search bar in the search page, click the left mouse button twice, and the previously searched history will appear. Then point with your mouse to the history you want to delete (Note: >>>More

9 answers2024-04-18

Writing ideas:You can write a record of the growth of bean sprouts and garlic seedlings, and plant them at home so that you can observe the records, check what kind of changes the plants have every day, and then record them fluently and clearly. >>>More