76 words

JDO PersistenceCapable Interface for Enhanced Classes

#1
2015-12-06 01:15

Hallo,

 

in old JDO 1.0 project we use the PersistenceCapable interface like this

    Model model = new Model();
    Model datas List models = new ArrayList();
    models.add((PersistenceCapable) model);

the interface was enhanced to the class.

in the new version we get this
java.lang.ClassCastException: Model cannot be cast to javax.jdo.spi.PersistenceCapable
give it an workaround or so?

aqua2011
aqua2011's picture
Joined on 2011-03-21
User Post #1
#2
2015-12-06 09:51

Since JDO 2.0 implementing the javax.jdo.spi.PersistenceCapable is optional, and the ObjectDB 2.x Enhancer does not implement that interface.

You should remove the casting and change your code to:

    models.add(model);

 

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

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.
Attachments:
Maximum file size: 32 MB
Cancel