ObjectDB ObjectDB

Schema update: package, class and field

#1

Hello,

how can it be specified in the schema, that an entity is moved to another package?

Package Structure (version 1)

com
  |- btc
       |- impl
            |- Class1.java
       |- internal
            |- Class2.java
            |- Class3.java

Now I want to move Class2   from com.btc.internal to com.btc.impl

com
  |- btc
       |- impl
            |- Class1.java
            |- Class2.java
       |- internal
            |- Class3.java

How should that be specified in the schema?

 

I found in the manual only how a whole packet can be renamed:

<schema>
  <package name="com.btc.internal" new-name="com.btc.impl" />
</schema>

But Class3 shall not be moved.

 

Or we can specify it like this:

<schema>
  <package name="com.btc" new-name="com.btc" >
    <class name="internal.Class2" new-name="impl.Class2" />
  </package>
</schema>
edit
delete
#2

Try:

<schema>
  <package name="com.btc.internal">
    <class name="Class2" new-name="com.btc.impl.Class2" />
  </package>
</schema>
ObjectDB Support
edit
delete
#3

Thanks. It works.

edit
delete
#4

It does work for entities classes but not for embeddable classes.

Do you have a solution for embeddable classes?

edit
delete
#5

There should not be a difference between entity and embeddable classes regarding schema changes. Maybe you are trying an embeddable class which is also an inner class (and that makes a difference in the name of the class)?

ObjectDB Support
edit
delete
#6

You're right, it works for embeddable classes.

But a combination of moving a class and rename a field of the class doesn't works.

 

I had extended a example in which i already rename a field.

Only rename the field  [example works]

<package name="com.btc.ep.base.bl.internal.dmos.message">
     <class name="TokenImpl">
       <field name="string" new-name="value" />
      </class>
</package>

 

Only move the (embeddable) class [example works too]

<package name="com.btc.ep.base.bl.internal.dmos.message">
     <class name="TokenImpl" new-name="com.btc.ep.base.bl.internal.dmos.newmessagepackage.TokenImpl" />
</package>

 

But the combination move and rename failed. All 'value' fields are 'null'

<package name="com.btc.ep.base.bl.internal.dmos.message">
     <class name="TokenImpl" new-name="com.btc.ep.base.bl.internal.dmos.newmessagepackage.TokenImpl">
       <field name="string" new-name="value" />
      </class>
</package>
edit
delete
#7

Thank you for this report. Please try build 2.6.3_02 that should fix this issue.

ObjectDB Support
edit
delete
#8

Thanks. It works.

 

I have a question about moving or renaming:

Is it allowed to move or rename a field or a class and create directly a new one with the original name?

Currently this works as we expected.

Is it ensured that ObjectDB also in the future first processed the "defined" schema update and then the "automatic" schema update or is that a coincidence?

 

Example:

Version 1:

class A {
   String date;
}

Version 2:

class A {
   String old_date; //renamed
   Date date;
}

Schema:

..
  <class name="A">
    <field name="date" new-name="old_date" />
  </class>
..

We expect following:

version1: ( date="21.07.2015" )     converted to  

version2: ( old_date="21.07.2015"; date=null)

edit
delete
#9

Interesting. This situation has not been addressed.

If it works it will probably work also in future versions, since there are no plans to rewrite the schema update mechanism (which generally works well), but you will have to be aware and report if it stops working in a future version.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.