0

Seems to me that they should, since the database that stores the objects can reside on a remote machine. But apparently it doesn't need to be the case from my experiments. So how does Hibernate handle remote object fetching? Or does it make all mapped classes implement Serializable using bytecode rewriting?

JRR
  • 6,014
  • 6
  • 39
  • 59

1 Answers1

2

Hibernate doesn't pass entity instances to the database. It executes SQL queries returning (or passing) the state of the entities, using JDBC. So the fact that the database is on a remote machine is irrelevant: Hibernate uses a JDBC driver to talk to the database, and entities are not serialized by Hibernate.

It can be necessary to make entities serializable if YOU want to serialize entities, but it's not necessary otherwise.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255