JPA Questions et reponses d'entretien
Differences associees
Question 21. On each of the four statuses of Entity objects, how are the operations persisted?
- For the new status, the object will get saved to the database after a transaction is committed and changes to the status managed.
- If the status is managed, it ignores the operation. But the status of the dependent Entity can be changed to 'managed' if the cascading annotations are there.
- For the removed status, it changes to managed thereafter.
- For the detached status, it throws the exception at the transaction's commit stage or right away.
Est-ce utile ?
Ajouter un commentaire
Voir les commentaires
Question 22. What are the effects on the statuses of Entity objects of the merge operation?
- For the new status, a new managed entity is created, and the past data will be copied into it.
- For the managed status, it ignores the operation, but it works on the Entity dependent on cascading when the status is not managed.
- For the removed status, it throws the exception at the transaction's commit stage or right away.
- For the detached status, it either creates a new managed with the data copied or copies the data to the existing managed Entity
Est-ce utile ?
Ajouter un commentaire
Voir les commentaires
Question 23. What are the effects on the statuses of Entity objects of the remove operation?
- For the new status, it ignores the operation, but the status changes to removed on the Entity dependent on cascading. Here the status shouldn't be managed.
- For the managed status, the status changes to removed thereafter, and the removed database records the object during the commit stage.
- For the removed status, it ignores the operation.
- For the detached status, it throws the exception at the transaction's commit stage or right away.
Est-ce utile ?
Ajouter un commentaire
Voir les commentaires
Question 24. What are the effects on the statuses of Entity objects of the detach operation?
- For the new or detached status, it ignores the operation.
- For the managed or removed status, the Entity's status and also of the objects dependent on cascade become detached.
Est-ce utile ?
Ajouter un commentaire
Voir les commentaires
Question 25. What are the effects on the statuses of Entity objects of the refresh operation?
- For the new, detached, or removed status, it throws out the exception.
- For the managed status, it restores all the changes from the database and refreshes all objects dependent on the cascade.
Est-ce utile ?
Ajouter un commentaire
Voir les commentaires
Les plus utiles selon les utilisateurs :
- What is ORM in JPA?
- What is an EntityManager?
- What is the difference between persistence.xml and hibernate.cfg.xml?
- What is an Entity?
- Why to use JPA?