I am new in JPA and I can't understand the use and the difference between stateless and stateful.
Any experiences?
regards, Haythem
Stateless and Stateful are EJB Session Bean concept, not of JPA.
Nota bene: JPA is part of EJB specification, but can be used separately and outside of an EJB container. This is what usually causes the confusion.
Edited: A useful SO thread, Why Use Stateful Session Beans.
"Stateful" and "Stateless" are attributes for session beans.
A session bean (in brief) provides a way to call methods on an application server. The bean is an instance of a java class. Usually, a bean is destroyed after the remote method terminates (and returns a result). Those bean are "stateless".
It is possible (but rather unusual) to add fields and attributes to the bean so that a client can "create" this instance on the server and use it for more then one operation. Those beans are "stateful" (and should be avoided).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With