Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving value from objectdb database from program
    text
    copied!<p>I am facing some problems while I am trying to fetch data through the program. I am using objectDB as my database. Also, my database is already set up and I have dropped the laptop.odb file in the db folder of my objectDB installation. Also, when I go to the explorer and fire the query:</p> <p><code>select this.modelName == "HP Pavillion"</code></p> <p>correct results comes up. But, when I try to do the same thing with my code as in the following </p> <p><code>public static void main(String argv[]) {<br> PersistenceManager pm = Utilities.getPersistenceManager("laptop.odb"); System.out.println("-- TEST --\n");<br> Query query = pm.newQuery(Laptop.class,"this.modelName == \"HP Pavillion\""); Collection result = (Collection)query.execute(); System.out.println("Result is &gt;&gt; "+result); </code></p> <p>Here no results are returned. My output is :<br> -- TEST find --</p> <p>Result is >> []</p> <p>My code for the class is the following. </p> <pre><code> package com.project; import java.util.*; import javax.annotation.processing.Processor; import javax.jdo.*; import com.objectdb.Utilities; public class Laptop { String modelName; // key public static void main(String argv[]) { PersistenceManager pm = Utilities.getPersistenceManager("laptop.odb"); System.out.println("-- TEST find --\n"); Query query = pm.newQuery(Laptop.class,"this.modelName == \"HP Pavillion\""); Collection result = (Collection)query.execute(); System.out.println("Result is &gt;&gt; "+result); } </code></pre> <p>Any suggestions ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload