Bug 400685 - Native MongoDB query like drop don't work
Summary: Native MongoDB query like drop don't work
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 major with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: mongodb
Keywords: core
Depends on:
Blocks:
 
Reported: 2013-02-13 08:57 EST by jm collin CLA
Modified: 2022-06-09 10:31 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jm collin CLA 2013-02-13 08:57:05 EST
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();
	
}
Comment 1 James Sutherland CLA 2013-03-27 11:15:13 EDT
Please include the exception stack trace.
Comment 2 James Sutherland CLA 2013-03-27 11:16:49 EDT
Try executeUpdate() instead of getSingleResult() (no result from a drop)
Comment 3 jm collin CLA 2013-03-27 12:14:26 EDT
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.
Comment 4 Tom Ware CLA 2013-04-03 08:47:47 EDT
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.
Comment 5 Frank Caputo CLA 2015-09-29 07:21:13 EDT
This one still happens on 2.6.1-RC1. As long as this isn't fixed, eclipselink is useless for mongodb.
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:31:35 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink