Embedded in JDO metadata not working in objectDB 2.x ?

#1

Hi,

I am using JDO access to the database with the persistence defined in package.jdo XML metadata files. In those metadata files I have few persistence-capable classes which had extents in ObjectDB 1 (with an OID for every instance) and all other classes were embedded (so without extent and own OID) in those few peristence-capable ones.

Example of JDO metadata:

<class name="ProjectPart">
  <field name="rackGroupList" embedded="true"/>
</class>

<class name="RackGroupList">
   <field name="list" embedded="true">
     <collection embedded-element="true" />
   </field> 
</class>

So as You see in the example I have the instances of RackGroupList embedded inside the instance of ProjectPart and the elements inside the RackGroupList are embedded too.

 

I did not change the metadata when I was moving from ObjectDB 1 to 2, I only adjusted the neccessary code to access the database (JDOConnection, etc.) and converted the DB files.

After conversion I got a slightly smaller file with same number of objects (e.g. 3,3GB old file -> 3GB new file).

However after using the v2 database in the same manner as before the embedding seems to be ignored. after 3 weeks of usage I have a db file of 12GB with 250 000 000 objects instead of the original 360 000 at the time of conversion.

Additionally I see in the DB Explorer every class as not embedded, with own extent and OID for every instance.

So my questions are:

1. Is the enormous increase of database file size caused by the number of not-embedded objects in ObjectDB 2 opposed to embedded ones in objectDB 1 ?

2. Could be that ObjectDB 2 is ignoring the "embedded=true" attribute in the package.jdo XML ? If yes, how to handle this ?

3. Should the @Embedded annotations work better ?

4. Is there some way to convert a database file with these not-embedded objects to an equivalent file with embedded objects ?

Thx,

JG

#2

Hi,

I found the answers for questions 2 and 3. So it was my mistake that I missed the point in the upgrade steps about the change in the way objects are embedded. So I should have used 

<class name="MyClass" embedded-only="true">

in package.jdo. Btw, is this declaration equivalent to the @EmbeddedOnly  JDO annotation ?

Questions 1 and 4 (especially) are still valid and unanswered.

Thx,

JG

#3

> is this declaration equivalent to the @EmbeddedOnly  JDO annotation ?

Yes.

> 1. Is the enormous increase of database file size caused by the number of not-embedded objects in ObjectDB 2 opposed to embedded ones in objectDB 1 ?

It may be the reason.

> 4. Is there some way to convert a database file with these not-embedded objects to an equivalent file with embedded objects ?

No such utility. After upgrading the schema you will have to write a small program that retrieves all the relevant containing entity objects, makes them dirty and persists them. Check that new embedded objects are created and then delete all the unwanted entity objects that the new embedded objects replace.

 

ObjectDB Support
#4

Thanks for the tip for question 4. I upgraded the schema and wrote the program which retrieves the containing entities, made them dirty and persisted them. So far everything went smooth, the new embedded objects were created, but how can I delete now the unwanted entity objects? Since I upgraded the schema where these objects are declared as embedded, I do not see them in the Explorer and can not make a query on them.

#5

Try running the delete query from a small console application.

If it doesn't work you may have to set the class as entity again (just for the query) and then back to embeddable.

Alternatively, probably running the Doctor in repair mode will create a smaller database without the old entities.

ObjectDB Support

Reply