nerdexam
Oracle

1Z0-900 · Question #39

When should a JPA entity implement the Serializable interface?

The correct answer is D. when JPA entities are used as parameters or return values by the remote EJB operations. Implementing Serializable is required when a JPA entity is passed as a parameter or returned from a remote EJB method, because remote calls use Java's serialization mechanism to marshal objects across the network (or JVM boundaries). Option A is wrong because the EJB Full…

Manage Persistence using JPA Entities and BeanValidation

Question

When should a JPA entity implement the Serializable interface?

Options

  • Awhen JPA entities are used in the EJB Full container
  • Bwhen JPA entities are used outside of the EJB Lite container
  • Calways, because JPA entities are required to implement the Serializable interface
  • Dwhen JPA entities are used as parameters or return values by the remote EJB operations

How the community answered

(27 responses)
  • A
    7% (2)
  • B
    19% (5)
  • C
    4% (1)
  • D
    70% (19)

Explanation

Implementing Serializable is required when a JPA entity is passed as a parameter or returned from a remote EJB method, because remote calls use Java's serialization mechanism to marshal objects across the network (or JVM boundaries). Option A is wrong because the EJB Full container doesn't inherently mandate serialization - it's the remote interface that does. Option B inverts the logic; being "outside the EJB Lite container" is not a defined trigger for serialization. Option C is wrong because JPA itself makes no such requirement - the JPA spec explicitly states that entities should implement Serializable only if they need to be detached and passed around remotely, not universally.

Memory tip: Think "remote = serialize." Remote EJB calls cross a boundary that Java can't bridge without serialization, so any entity that travels over that wire must be serializable. If it stays local, it doesn't need to be.

Topics

#JPA Entities#Serialization#Remote EJB#RMI

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice