Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Mongodb compatible versions(Mongodb compatible versions)
Mongodb compatible versions [message #1724979] Sun, 28 February 2016 13:22
Ahmed Farag is currently offline Ahmed FaragFriend
Messages: 1
Registered: February 2016
Junior Member
Hi Everyone,
I want to create J2EE application using Weblogic 11g and Mongod, but i do not know What is the compatible versions of eclipselink and mongodb, Any help is appreciated.

I used weblogic 12c which contains eclipselink 2.6.1 with mongo-java-driver-2.14.1.jar, Thanks to this Topic and it works fine with jpql query but throws the below exception when using native query.

package core.entity;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;

import org.eclipse.persistence.nosql.annotations.DataFormatType;
import org.eclipse.persistence.nosql.annotations.Field;
import org.eclipse.persistence.nosql.annotations.NoSql;

@Entity

@NoSql(dataType = "Logs", dataFormat = DataFormatType.MAPPED)
public class Log {

    @Id
    @GeneratedValue
    @Field(name = "_id")
    private String id;

    @Version
    private long version;

    @Basic
    @Field(name = "EnglishName")
    private String englishName;

    public void setId(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    public long getVersion() {
        return version;
    }

    public void setEnglishName(String englishName) {
        this.englishName = englishName;
    }

    public String getEnglishName() {
        return englishName;
    }
}


package core.business;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

public class Test {

    EntityManagerFactory factory;
    static String oid;

    public static void main(String[] args) throws Exception {
        Test test = new Test();

        test.factory = Persistence.createEntityManagerFactory("logging");

        test.testFind();
        test.factory.close();
    }

    public void testFind() {
        EntityManager em = factory.createEntityManager();

        Query query = em.createNativeQuery("db.Logs.count()");

        query.getSingleResult();

        em.close();
    }
}


    <persistence-unit name="logging" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>core.entity.Log</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.target-database"
                      value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
            <property name="eclipselink.nosql.connection-spec"
                      value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"/>
            <property name="eclipselink.nosql.property.mongo.port" value="27017"/>
            <property name="eclipselink.nosql.property.mongo.host" value="localhost"/>
            <property name="eclipselink.nosql.property.mongo.db" value="logging"/>
        </properties>
    </persistence-unit>


Caused by: java.lang.ClassCastException: org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform cannot be cast to org.eclipse.persistence.platform.database.DatabasePlatform
	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.getPlatform(DatabaseSessionImpl.java:505)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.usesBinding(DatabaseCall.java:1233)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:1056)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:241)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:228)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:299)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelect(DatasourceCallQueryMechanism.java:281)
	at org.eclipse.persistence.queries.DataReadQuery.executeNonCursor(DataReadQuery.java:197)
	at org.eclipse.persistence.queries.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:152)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:904)
	at org.eclipse.persistence.queries.DataReadQuery.execute(DataReadQuery.java:137)
	at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:803)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1857)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
	at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
	at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:521)


Thanks

[Updated on: Tue, 01 March 2016 12:59]

Report message to a moderator

Previous Topic:NullPointerException failed to process remote command
Next Topic:Excluding specific fields when using OptimisticLockingType.CHANGED_COLUMNS
Goto Forum:
  


Current Time: Wed Mar 03 03:09:12 GMT 2021

Powered by FUDForum. Page generated in 0.01895 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top