Community
Participate
Working Groups
When trying to drop a collection with a native query we ran into this error : java.lang.ClassCastException: org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform cannot be cast to org.eclipse.persistence.platform.database.DatabasePlatform The piece of code is the following : public void cleanAll() throws Exception { Query query = _context.getEntityManager().createNativeQuery("db.INVOICE.drop()"); query.getSingleResult(); }
Please include the exception stack trace.
Try executeUpdate() instead of getSingleResult() (no result from a drop)
This code : try { beginEntityManager(); beginTransaction(); Query q = getEntityManager().createNativeQuery("db.invoice.drop()"); q.executeUpdate(); commitTransaction(); endEntityManager(); } catch (Exception e) { log.error("Error while dropping", e); } produce the following stacktrace and logs : INFO Version - HV000001: Hibernate Validator 4.3.1.Final [EL Info]: 2013-03-27 17:12:52.199--ServerSession(1895272766)--EclipseLink, version: Eclipse Persistence Services - 2.4.1.v20121003-ad44345 [EL Info]: connection: 2013-03-27 17:12:52.44--ServerSession(1895272766)--file:/E:/jmc/Projets/clouderial/workspace/services/services-ejb/target/classes/_clouderial_pu login successful [EL Warning]: 2013-03-27 17:12:52.517--UnitOfWork(781582357)--Exception [EclipseLink-7108] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException Exception Description: This operation is not supported for non-relational platforms. ERROR BaseServicesTestCase - Error while dropping Local Exception Stack: Exception [EclipseLink-7108] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.ValidationException Exception Description: This operation is not supported for non-relational platforms. at org.eclipse.persistence.exceptions.ValidationException.notSupportedForDatasource(ValidationException.java:567) at org.eclipse.persistence.sessions.DatasourceLogin.getPlatform(DatasourceLogin.java:202) at org.eclipse.persistence.internal.sessions.AbstractSession.getPlatform(AbstractSession.java:2528) at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.usesBinding(DatabaseCall.java:1153) at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:976) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:236) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelect(DatasourceCallQueryMechanism.java:216) at org.eclipse.persistence.queries.DataModifyQuery.executeDatabaseQuery(DataModifyQuery.java:85) at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:852) at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:751) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2875) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1602) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1584) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1549) at org.eclipse.persistence.internal.jpa.QueryImpl.executeUpdate(QueryImpl.java:286) at clouderial.saas.services.test.BaseServicesTestCase.setUp(BaseServicesTestCase.java:88) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) I hope this help.
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
This one still happens on 2.6.1-RC1. As long as this isn't fixed, eclipselink is useless for mongodb.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink