Collection Contents Index Returning result sets from Java methods Java database design pdf/chap17.pdf

User's Guide
   PART 3. Java in the Database
     CHAPTER 17. Using Java in the Database       

How Java objects are stored


Java values are stored in serialized form. This means that each row contains the following information:

The class definition is not stored for each row. Instead, the identifier provides a reference to the class definition, which is held only once.

You can use Java objects without knowing the details of how these pieces work, but the way in which the objects are stored does have some implications for performance and so information is provided here.

Notes 

Top of page  Java objects and class versions

Java objects stored in the database are persistent; that is, they exist even when no code is running. This means that you could carry out the following sequence of actions:

  1. Install a class.

  2. Create a table using that class as the data type for a column.

  3. Insert rows into the table.

  4. Install a new version of the class.

How will the existing rows work with the new version of the class?

Accessing rows when a class is updated 

Adaptive Server Anywhere provides a form of class versioning to allow the new class to work with the old rows. The rules for accessing these older values are as follows:

When objects are inaccessible 

A serialized object is not accessible if the class of the object or any of its superclasses has been removed from the database, at any time. This behavior is consistent with Sun Microsystems serialization.

Moving objects across databases 

These changes make cross database transfer of objects possible even when the versions of classes differ. Cross database transfer can occur as follows:

When the new class is used 

The class definition for each class is loaded by each connection's VM the first time that class is used.

When you INSTALL a class, the VM on your connection is implicitly restarted. Therefore, you have immediate access to the new class.

For connections other than the one that carries out the INSTALL, the new class is loaded the next time a VM accesses the class for the first time. If the class is already loaded by a VM, that connection does not see the new class until the VM is restarted for that connection (for example, with a STOP JAVA and START JAVA).

Top of page  

Collection Contents Index Returning result sets from Java methods Java database design pdf/chap17.pdf