ObjectDB ObjectDB

Non Embedded byte[]

#1

I am trying to understand the "embedded=false" for JDO byte[] as described in ObjectDB 1.0 Manual, sections 4.3 and 4.4.

 

I desire to store an image as a byte[] but I don't want the byte[] to be loaded on the loading of the persistent object that has my image's attributes.  The byte[] would only be loaded from the datastore if my image's attribute evaluation deemed that it need to be loaded.

 

Can you give a JDO example of how to achieve this?

 

For example:


@PersistenceCapable

class MyImage{

boolean isCurrent;


@Persist(embedded="false")byte[] imageData;

}

Would the above code allow me to load a persisted MyImage instance and imageData would NOT be requested from the datastore file at that time?  If I then did a "if(!myImage.isCurrent) return imageData;", would that THEN load the byte[] from the datastore file?

Is the imageData byte[], if not embedded, stored as a single "blob" as a unique ObjectDB persisted object?  (The section 4.4 talks about how each ELEMENT could be stored as a separate object, which would be no be desirable.)

edit
delete
#2

This setting is obsolete in ObjectDB 2.x. byte[] is always embedded and loaded eagerly.

You may use a wrapper entity object with a byte[] as its only field.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.