985 words

Extending model by "common entity"

2011-02-06 13:38


I have a question about extending working model with one, common entity, that all other entities will inherit from. For example I have 2 different entities in database with some data:

public class Entity1 implements Serializable {
    private String val1;
    private String val2;
    // (getters and setters here)
and the second one:
public class Entity2 implements Serializable {
    private String val4;
    // (getters and setters here)
Now I want to create BaseEntity which all common attributes:
public class BaseEntity implements Serializable {
    private String createdBy;
    private Date createdAt;
    private String modifiedBy;
    private Date modifiedAt;   
    // (getters and setters here)
Then Entity1 and Entity2 will be modified to inherit from BaseEntity, so:
public class Entity1 extends BaseEntity implements Serializable{}
And the same for Entity2. The problem is, that when I have some data in database, after compiling and running new version of application, I got some errors:
java.lang.NoClassDefFoundError: pl/hplxtool/model/BaseEntity
  at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.6.0_22]
  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) ~[na:1.6.0_22]
  at java.lang.ClassLoader.defineClass(ClassLoader.java:616) ~[na:1.6.0_22]
  at java.lang.ClassLoader.defineClass(ClassLoader.java:466) ~[na:1.6.0_22]
  at com.objectdb.o.ACL.e(ACL.java:175) ~[objectdb.jar:na]
  at com.objectdb.o.STL.h(STL.java:97) ~[objectdb.jar:na]
  at com.objectdb.o.TYM.findClass(TYM.java:954) ~[objectdb.jar:na]
  at com.objectdb.o.ACL.loadClass(ACL.java:137) ~[objectdb.jar:na]
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ~[na:1.6.0_22]
  at com.objectdb.o.TYM.at(TYM.java:931) ~[objectdb.jar:na]
  at com.objectdb.o.UTY.initSysType(UTY.java:317) ~[objectdb.jar:na]
  at com.objectdb.o.TYS.l(TYS.java:163) ~[objectdb.jar:na]
  at com.objectdb.o.TYM.aa(TYM.java:469) ~[objectdb.jar:na]
  at com.objectdb.o.TYM.<init>(TYM.java:229) ~[objectdb.jar:na]
  at com.objectdb.o.MST.aE(MST.java:175) ~[objectdb.jar:na]
  at com.objectdb.o.SHN.U(SHN.java:258) ~[objectdb.jar:na]
  at com.objectdb.o.SHN.I(SHN.java:108) ~[objectdb.jar:na]
  at com.objectdb.o.HND.run(HND.java:119) ~[objectdb.jar:na]
  at java.lang.Thread.run(Thread.java:662) [na:1.6.0_22]

Caused by: java.lang.ClassNotFoundException: pl.hplxtool.model.BaseEntity
  at com.objectdb.o.TYM.findClass(TYM.java:951) ~[objectdb.jar:na]
  at com.objectdb.o.ACL.loadClass(ACL.java:137) ~[objectdb.jar:na] at java.lang.ClassLoader.loadClass(ClassLoader.java:248) ~[na:1.6.0_22]
How can I propagate that kind of changes with ODB model? The same exceptions are thrown when I run explorer or doctor.
lwalkowski's picture
Joined on 2010-08-25
User Post #9
2011-02-06 14:15

This schema change should be handled by ObjectDB - so the exception is unexpected.

Maybe you have to restart the server (I see that the stack trace is generated by the server).

If it doesn't help - please post (or submit in a support ticket) a test case that demonstrates this exception.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #123
2011-02-06 14:25

Restart didn't help at all. I will prepare test case and submit a support ticket.

lwalkowski's picture
Joined on 2010-08-25
User Post #10
2011-02-06 19:53

Thank you for the test application - it demonstrates a bug in ObjectDB schema evolution.

Please check build 2.0.5_01 that should fix it.

If possible - apply the schema change again to a database that was used only with the old schema.

If you must repair a database file that was already used with the new schema - open it once in embedded mode from your application (not using the Explorer) - after rebuilding all the classes.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support's picture
Joined on 2010-05-03
User Post #124

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Maximum file size: 32 MB