Hi Bunty, Interesting configuration. I have not used the MySQL clustering support...
<property name="openjpa.BrokerFactory" value="ndb" /> <property name="openjpa.ndb.connectString" value="mysql-management2" /> <property name="openjpa.ndb.database" value="db" /> The "ndb" on the BrokerFactory must be some alias, but it's not defined by the standard OpenJPA code. Without some special extension in the OpenJPA bundle, this alias would not be recognized. From googling, I found other people have specified the full BrokerFactory name: com.mysql.clusterj.openjpa.NdbOpenJPABrokerFactory By specifying this special broker and making the necessary supporting class files available to OpenJPA, then your other openjpa.ndb.* properties will be recognized. I'm not sure if any of this rambling directly affects the issue you are having, but I'm trying to save other people the trouble of understanding your persistence.xml... The required use of this property normally indicates an error in the application: <property name="openjpa.Multithreaded" value="true"/> EntityManagers, by definition, are single threaded and should not be shared. Using this property normally highlights an issue with sharing of EMs. If your app does not work without this property, then you should re-examine your app to remove this EM sharing. The use of this property is unnecessarily slowing down your app due to all of the synchronization that has to be done to share EMs. Kind of strange to see eclipselink properties in an openjpa configuration: <property name="eclipselink.jdbc.batch-writing" value="JDBC"/> <property name="eclipselink.jdbc.batch-writing.size" value="1000"/> It's also kind of unique to use both SynchronizeMappings and SchemaFactory, but I would make the usage similar by adding the ForeignKey clause to SynchronizeMappings: <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/> Finally, the NPE you are getting looks to be caused by an incorrect configuration. Since it looks like you are trying to override the BrokerFactory, my guess is that something is not right with the MySQL Cluster setup and configuration. You might need to post your question to the MySQL team... Let us know what you figure out. Thanks, Kevin On Thu, Mar 14, 2013 at 8:47 AM, bunty <gurjantsing...@gmail.com> wrote: > Hi > > I am getting the below given exception when I try to connect to NDB cluster > using my java application. > > <openjpa-2.2.1-r422266:1396819 nonfatal general error> > org.apache.openjpa.persistence.PersistenceException: null > at > > org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:625) > at > org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:682) > at > > org.apache.openjpa.kernel.QueryImpl.getOrderedParameterTypes(QueryImpl.java:1577) > at > > org.apache.openjpa.kernel.DelegatingQuery.getOrderedParameterTypes(DelegatingQuery.java:396) > at > org.apache.openjpa.persistence.QueryImpl.getParamTypes(QueryImpl.java:648) > at > > org.apache.openjpa.persistence.AbstractQuery.getDeclaredParameters(AbstractQuery.java:497) > at > > org.apache.openjpa.persistence.AbstractQuery.getParameterValues(AbstractQuery.java:77) > at > org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:284) > at > org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302) > at com.cpt.calculations.SPYData.loadSPYData(SPYData.java:49) > at com.cpt.calculations.SPYData.getInstance(SPYData.java:29) > at > > com.cpt.calculations.CalculationsManager.performHistoricalCalculations(CalculationsManager.java:159) > at > > com.cpt.calculations.CalculationsManager.start(CalculationsManager.java:369) > at > com.cpt.calculations.CalculationsManager.main(CalculationsManager.java:421) > Caused by: java.lang.NullPointerException > at > > org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:154) > at > org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:672) > at > > org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:654) > at > > org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620) > ... 13 more > > > The persistence file is given below. > > <persistence xmlns="http://java.sun.com/xml/ns/persistence" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"> > <persistence-unit name="cpt" transaction-type="RESOURCE_LOCAL"> > <provider> org.apache.openjpa.persistence.PersistenceProviderImpl > </provider> > <class>com.calculations.className</class> > <properties> > PrettyPrintLineLength=500"/> --> > <property name="openjpa.DetachState" > value="fetch-groups(DetachedStateField=true)" /> > <property name="openjpa.jdbc.SchemaFactory" > value="native(ForeignKeys=true)" > /> > <property name="openjpa.AutoDetach" value="commit" /> > <property name="openjpa.Multithreaded" value="true"/> > <property name="openjpa.ConnectionUserName" value="db" /> > <property name="openjpa.ConnectionPassword" value="******" /> > <property name="openjpa.ConnectionURL" value="jdbc:mysql://******:3306/db" > /> > <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" > /> > <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/> > <property name="openjpa.jdbc.DBDictionary" value="batchLimit=500"/> > <property name="eclipselink.jdbc.batch-writing" value="JDBC"/> > <property name="eclipselink.jdbc.batch-writing.size" value="1000"/> > <property name="openjpa.BrokerFactory" value="ndb" /> > <property name="openjpa.ndb.connectString" value="mysql-management2" /> > <property name="openjpa.ndb.database" value="db" /> > value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict" > /> --> > </properties> > </persistence-unit> > </persistence> > > I am able to create the connection with the database but not able to fetch > the data. My java code is given below. > > Query query = > > EntityFactoryManager.getInstance().getEntityManager().createNativeQuery("select > r from tableName r WHERE r.symbol='SPY' order by r.date desc > ",className.class); > dataList= (List<className>)(query.getResultList()); > > Thanks in advance for help. > > -BUnty > > > > > > > > > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/Not-able-to-fetch-the-data-from-NDB-cluster-tp7583125.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >