Ambiguous entity name after package renaming

#1

I maintain an open source Java Swing application with 4 (ObjectDB) classes within 1 package.

I renamed the package. And now I get a Ambiguous entity name PersistenceException error with reference to both the entity names (old and new)

I now have 8 entities in de Explorer (4 old and 4 new). The new ones are empty.

I tried to use schema update method:

    >
         name="nl.old.oldie.db" new-name="nl.new.newby.db" />
             name="Class1" />
             name="Class2" />
             name="Class3" />
             name="Class4" />
    >

But it does nothing and the problem still occurs and stays the same.

Is there another way to rename the entities in de odb?

#2

Can you share the sample database with this issue?

ObjectDB Support
#3

Please also include a full stack trace of the exception.

ObjectDB Support
#4
Stacktrace:

[ObjectDB 2.9.0] javax.persistence.PersistenceException

Ambiguous entity name - Class1 (used by [nl.old.oldie.db.Class1,nl.new.newby.db.Class1]) (error 307)

at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:738)

at nl.new.newby.db.ObjectDatabase.querySingleResult(ObjectDatabase.java:101)

at nl.new.newby.db.SpelerDatabase.rondeExists(SpelerDatabase.java:205)

at nl.new.newby.SpelerDBImport.importStatusObject(SpelerDBImport.java:64)

at nl.new.newby.SpelerDBImport.importStatusObjectWithDBSession(SpelerDBImport.java:47)

at nl.new.newby.ui.view.Hoofdscherm.actieVolgendeRonde(Hoofdscherm.java:1282)

at nl.new.newby.ui.view.Hoofdscherm$26.actionPerformed(Hoofdscherm.java:588)

at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)

at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2314)

at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:407)

at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)

at java.desktop/javax.swing.AbstractButton.doClick(AbstractButton.java:374)

at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1029)

at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1073)

at java.desktop/java.awt.Component.processMouseEvent(Component.java:6621)

at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)

at java.desktop/java.awt.Component.processEvent(Component.java:6386)

at java.desktop/java.awt.Container.processEvent(Container.java:2266)

at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4996)

at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)

at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)

at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)

at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)

at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)

at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)

at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)

at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)

at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)

at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)

at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)

at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)

at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)

at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)

at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)

at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)

at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)

at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)

at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)

at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)

at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)

at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)

at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)

at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)

at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Caused by: com.objectdb.o.UserException: Ambiguous entity name - Class1 (used by [nl.old.oldie.db.Class1,nl.new.newby.db.Class1])

at com.objectdb.o.MSG.a(MSG.java:64)

at com.objectdb.o.TYM.q(TYM.java:932)

at com.objectdb.o.TYM.M(TYM.java:1087)

at com.objectdb.o.TRS.b(TRS.java:179)

at com.objectdb.o.SYR.g(SYR.java:261)

at com.objectdb.o.SYR.f(SYR.java:190)

at com.objectdb.o.QRC.<init>(QRC.java:158)

at com.objectdb.o.QRM.Z4(QRM.java:272)

at com.objectdb.o.MST.Z4(MST.java:1026)

at com.objectdb.o.WRA.Z4(WRA.java:313)

at com.objectdb.o.WSM.Z4(WSM.java:117)

at com.objectdb.o.QRR.k(QRR.java:260)

at com.objectdb.o.QRR.i(QRR.java:154)

at com.objectdb.jpa.JpaQuery.getResultList(JpaQuery.java:726)

... 43 more

 

 

#5

I was trying to get a sample database ready. Hard, because of some privacy issues.

I think I might have overlooked the fact that some fields are referring to one of the another classes (with is also renamed of course).

I think I might need to adjust the schema update for that ...

Is that a possible cause?

#6

In addition to my previous reply.

The names of the fields have not changed. Only the classes (Class name have not changed but the package name of it) behind it. Do I need to change it and how?

Regards

#7

The cause is probably due to applying the schema update in the wrong order. When ObjectDB first sees the new class the schema update configuration must be available and correct. If it is not available (or wrong) then you get a new class and also keep the old class and schema update is unfortunately not applicable anymore.

As a quick solution for the exception - specify the full class name including package name (of the old class with the objects) in the query, and this should eliminate the ambiguity.

To complete the schema evolution you can try deleting the new classes in the Explorer first, move back to the old class name in your code, maybe also create a new database by running the Doctor in repair mode, and then try schema update in the correct order again. Success is not guaranteed.

ObjectDB Support
#8

OK. I am able to get back to an older version of the database (before any try with schema update).

Should I create a special routine to do the update in the correct order?

In the attachement a screenshot of the database (with the new package names). As you see they are empty.

You can see there seems to be a possible loop in the fields references (although a List is used).

Can you help me with the correct order to do the update?

#9

ObjectDB must see the new classes and the schema changes in the configuration at the same time, so make the changes when the database is not in use and then start your application and access the database.

See also the guidelines in #7 above.

 

ObjectDB Support

Reply