java - How can I determine if a JPA entity was read from the database or not? -


is there way find out if entity read database or not?

this question related how know if detached jpa entity has been persisted or not?. workaround check primary key not answer question. not work entities primary keys read import file or so.

to extend question:

how jpa implementations determine if entity inserted or updated?

hibernate uses value of field annotated @version (for optimistic locking), if present, tell if entity transient or detached. same.

otherwise, no, there's no way. pojo pojo. , hibernate uses value of primary key if no @version field present.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -