2

我是 Java Beans 的新手。我已经读过,为了使 Java Bean 持久化,它们的类必须扩展 Serializable 类。他们坚持到什么时候?直到JVM重新启动?

4

2 回答 2

2

It depends where you have persisted the data.

If you have persisted data into a file then it will remain till you delete the file explicitly. This file could be used to reconstruct the object whenever required.

If you persist data over a wire and reconstruct the object again then it will remain depending on its scope (Garbage collection) and will definitely be removed once JVM is killed.

于 2013-10-10T09:58:44.477 回答
1

持久性意味着将它们保存到数据库中。我们在 java 中有许多 ORM(对象关系映射)库,如 Hibernate、Data Nucleus 等。您可以使用 ORM 库将 Java bean 对象持久保存到数据库中,当您再次从数据库中获取时,您可以获得 Java Bean 对象的集合。

于 2013-10-10T10:00:58.107 回答