Search Results

Search found 15 results on 1 pages for 'jdoql'.

Page 1/1 | 1 

  • Declarative JDOQL vs Single-String JDOQL : performance

    - by DrDro
    When querying with JDOQL is there a performance difference between using the declarative version and the Single-String version: Example from the JDOQL doc: //Declarative JDOQL : Query q = pm.newQuery(org.jpox.Person.class, "lastName == \"Jones\" && age < age_limit"); q.declareParameters("double age_limit"); List results = (List)q.execute(20.0); //Single-String JDOQL : Query q = pm.newQuery("SELECT FROM org.jpox.Person WHERE lastName == \"Jones\"" + " && age < :age_limit PARAMETERS double age_limit"); List results = (List)q.execute(20.0); Other then performance, are there any reasons for which one is better to use then the other or is it just about the one with which we feel more comfortable.

    Read the article

  • Query by datetime in JDOQL / Java / GAE

    - by Jan Kuboschek
    I'm working on a GAE app. I want to query datastore and retrieve all records between startDate and endDate. Each record has a datetime field. I'm using a query similar to this (the below code is something I quickly grabbed - I'm not near my developer machine.): Query query = pm.newQuery(Employee.class); query.setFilter("lastName == lastNameParam"); query.setOrdering("hireDate desc"); query.declareParameters("String lastNameParam"); try { List results = (List) query.execute("Smith"); if (results.iterator().hasNext()) { for (Employee e : results) { // ... } } else { // ... no results ... } } finally { query.closeAll(); } How do I have to format the date to form a correctly working query? How is the datetime stamp stored in datastore? As timestamp? Fully formatted? I can't find ANY information on this. Please help.

    Read the article

  • Filter a date property between a begin and end Dates with JDOQL

    - by Sergio del Amo
    I want to code a function to get a list of Entry objects whose date field is between a beginPeriod and endPeriod I post below a code snippet which works with a HACK. I have to substract a day from the begin period date. It seems the condition great or equal does not work. Any idea why I have this issue? public static List<Entry> getEntries(Date beginPeriod, Date endPeriod) { /* TODO * The great or equal condition does not seem to work in the filter below * Substract a day and it seems to work */ Calendar calendar = Calendar.getInstance(); calendar.set(beginPeriod.getYear(), beginPeriod.getMonth(), beginPeriod.getDate() - 1); beginPeriod = calendar.getTime(); PersistenceManager pm = JdoUtil.getPm(); Query q = pm.newQuery(Entry.class); q.setFilter("this.date >= beginPeriodParam && this.date <= endPeriodParam"); q.declareParameters("java.util.Date beginPeriodParam, java.util.Date endPeriodParam"); List<Entry> entries = (List<Entry>) q.execute(beginPeriod,endPeriod); return entries; }

    Read the article

  • Persistance JDO - How to query a property of a collection with JDOQL?

    - by Sergio del Amo
    I want to build an application where a user identified by an email address can have several application accounts. Each account can have one o more users. I am trying to use the JDO Storage capabilities with Google App Engine Java. Here is my attempt: @PersistenceCapable @Inheritance(strategy = InheritanceStrategy.NEW_TABLE) public class AppAccount { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; @Persistent private String companyName; @Persistent List<Invoices> invoices = new ArrayList<Invoices>(); @Persistent List<AppUser> users = new ArrayList<AppUser>(); // Getter Setters and Other Fields } @PersistenceCapable @EmbeddedOnly public class AppUser { @Persistent private String username; @Persistent private String firstName; @Persistent private String lastName; // Getter Setters and Other Fields } When a user logs in, I want to check how many accounts does he belongs to. If he belongs to more than one he will be presented with a dashboard where he can click which account he wants to load. This is my code to retrieve a list of app accounts where he is registered. public static List<AppAccount> getUserAppAccounts(String username) { PersistenceManager pm = JdoUtil.getPm(); Query q = pm.newQuery(AppAccount.class); q.setFilter("users.username == usernameParam"); q.declareParameters("String usernameParam"); return (List<AppAccount>) q.execute(username); } But I get the next error: SELECT FROM invoices.server.AppAccount WHERE users.username == usernameParam PARAMETERS String usernameParam: Encountered a variable expression that isn't part of a join. Maybe you're referencing a non-existent field of an embedded class. org.datanucleus.store.appengine.FatalNucleusUserException: SELECT FROM com.softamo.pelicamo.invoices.server.AppAccount WHERE users.username == usernameParam PARAMETERS String usernameParam: Encountered a variable expression that isn't part of a join. Maybe you're referencing a non-existent field of an embedded class. at org.datanucleus.store.appengine.query.DatastoreQuery.getJoinClassMetaData(DatastoreQuery.java:1154) at org.datanucleus.store.appengine.query.DatastoreQuery.addLeftPrimaryExpression(DatastoreQuery.java:1066) at org.datanucleus.store.appengine.query.DatastoreQuery.addExpression(DatastoreQuery.java:846) at org.datanucleus.store.appengine.query.DatastoreQuery.addFilters(DatastoreQuery.java:807) at org.datanucleus.store.appengine.query.DatastoreQuery.performExecute(DatastoreQuery.java:226) at org.datanucleus.store.appengine.query.JDOQLQuery.performExecute(JDOQLQuery.java:85) at org.datanucleus.store.query.Query.executeQuery(Query.java:1489) at org.datanucleus.store.query.Query.executeWithArray(Query.java:1371) at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:243) at com.softamo.pelicamo.invoices.server.Store.getUserAppAccounts(Store.java:82) at com.softamo.pelicamo.invoices.test.server.StoreTest.testgetUserAppAccounts(StoreTest.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) 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) Any idea? I am getting JDO persistance totally wrong?

    Read the article

  • JDOQL Any way to avoid multiple .contains() calls in the query when searching for the presence of on

    - by Finbarr
    The question pretty much says it all. If I have a class Class A public class A { ... private List<String> keys; ... } And I want to select all A instances from the DataStore that have atleast one of a List of keys, is there a better way of doing it than this: query = pm.newQuery(A.class); query.setFilter("keys.contains(:key1) || keys.contains(:key2) || keys.contains(:key3)"); List<A> results = (List<A>)query.execute(key1, key2, key3); This has not yet been implemented, so I am open to radical suggestions.

    Read the article

  • Store java.util.Calendar field into one column

    - by Rasika
    How to store java.util.Calendar field into one column with Datanucleus JDO. By default it is stored into two columns (millisecs, Timezone) with following JDO metadata. field name="startDate" serialized="true" embedded="true" persistence-modifier="persistent" What need to be changed in metadata to store it into single column (Timestamp)? Is it posible query (JDOQL) on calendar field when it is in two clumn?

    Read the article

  • Subqueries on Java GAE Datastore

    - by Dmitry
    I am trying to create a database of users with connection between users (friends list). There are 2 main tables: UserEntity (main field id) and FriendEntity with fields: - initiatorId - id of user who initiated the friendship - friendId - id of user who has been invited. Now I am trying to fetch all friends of one particular user and encountered some problems with using subqueries in JDO here. Logically the query should be something like this: SQL: SELECT * FROM UserEntity WHERE EXISTS (SELECT * FORM FriendEntity WHERE (initiatorId == UserEntity.id && friendId == userId) || (friendId == UserEntity.id && initiatorId == userId)) or SELECT * FROM UserEntity WHERE userId IN (SELECT * FROM FriendEntity WHERE initiatorId == UserEntity.id) OR userId IN (SELECT * FROM FriendEntity WHERE friendId == UserEntity.id) So to replicate the last query in JDOQL, I tried to do the following: Query friendQuery = pm.newQuery(FriendEntity.class); friendQuery.setFilter("initiatorId == uidParam"); friendQuery.setResult("friendId"); Query initiatorQuery = pm.newQuery(FriendEntity.class); initiatorQuery.setFilter("friendId == uidParam"); initiatorQuery.setResult("initiatorId"); Query query = pm.newQuery(UserEntity.class); query.setFilter("initiatorQuery.contains(id) || friendQuery.contains(id)"); query.addSubquery(initiatorQuery, "List initiatorQuery", null, "String uidParam"); query.addSubquery(friendQuery, "List friendQuery", null, "String uidParam"); query.declareParameters("String uidParam"); List<UserEntity> friends = (List<UserEntity>) query.execute(userId); In result I get the following error: Unsupported method while parsing expression. Could anyone help with this query please?

    Read the article

  • How to do this GQL query in JDO

    - by TheDon
    I have about 50k entities stored in appengine. I am able to look up an individual record via the GQL admin interface with a query like: SELECT * FROM Pet where __key__ = KEY( 'Pet','Fido') But I'm having trouble figuring out how to do a batch version of this via JDO. Right now I have this: PersistenceManager pm = ...; for(Pet pet : pets) { for(String k : getAllAliases(pet)) { keys.add(KeyFactory.createKeyString(Pet.class.getSimpleName(), k)); } } Query q = pm.newQuery("select from " + Pet.class.getName() + " where id == :keys"); List<Pet> petlist = (List<Pet>) q.execute(keys); But though 'Fido' works in the GQL case, it returns nothing when I use that Java + JDO code. What am I doing wrong?

    Read the article

  • AppEngine JDO-QL : Problem with multiple AND and OR in query

    - by KlasE
    Hi, I'm working with App Engine(Java/JDO) and are trying to do some querying with lists. So I have the following class: @PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") public class MyEntity { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) Key key; @Persistent List<String> tags = new ArrayList<String>(); @Persistent String otherVar; } The following JDO-QL works for me: ( tags.contains('a') || tags.contains('b') || tags.contains('c') || tags.contains('d') ) && otherVar > 'a' && otherVar < 'z' This seem to return all results where tags has one or more strings with one or more of the given values and together with the inequality search on otherVar But the following do not work: (tags.contains('a') || tags.contains('_a')) && (tags.contains('b') || tags.contains('_b')) && otherVar > 'a' && otherVar < 'z' In this case I want all hits where there is at least one a (either a or _a) and one b (either b or _b) together with the inequality search as before. But the problem is that I also get back the results where there is a but no b, which is not what I want. Maybe I have missed something obvious, or done a coding error, or possibly there is a restriction on how you can write these queries in appengine, so any tips or help would be very welcome. Regards Klas

    Read the article

  • App Engine datastore does not support operator OR

    - by JohnIdol
    I am trying to query the google datastore for something like (with pm -- persistanceManager): String filters = "( field == 'value' || field == 'anotherValue' )"; Query query = pm.newQuery(myType.class, filters); When I execute - I am getting back: App Engine datastore does not support operator OR. What's the best approach in people experience for this kind of queries? Any help appreciated!

    Read the article

  • Deserializing only select properties of an Entity using JDOQL query string?

    - by user246114
    Hi, I have a rather large class stored in the datastore, for example a User class with lots of fields (I'm using java, omitting all decorations below example for clarity): @PersistenceCapable class User { private String username; private String city; private String state; private String country; private String favColor; } For some user queries, I only need the favColor property, but right now I'm doing this: SELECT FROM " + User.class.getName() + " WHERE username == 'bob' which should deserialize all of the entity properties. Is it possible to do something instead like: SELECT username, favColor FROM " + User.class.getName() + " WHERE username == 'bob' and then in this case, all of the returned User instances will only spend time deserializing the username and favColor properties, and not the city/state/country properties? If so, then I suppose all the other properties will be null (in the case of objects) or 0 for int/long/float? Thank you

    Read the article

  • Google App Engine and SQL LIKE

    - by jb
    Is there any way to query GAE datastore with filter similar to SQL LIKE statement? For example, if a class has a string field, and I want to find all classes that have some specific keyword in that string, how can I do that? It looks like JDOQL's matches() don't work... Am I missing something? Any comments, links or code fragments are welcome

    Read the article

  • GAE more than 3 attributes to filter?

    - by Vik
    Hie I am using GAE jdoql and wrote query like: Query query = pm.newQuery(BloodDonor.class); query.setFilter(" state == :stateName && district == :distName &&" + " city == :cityName && bloodGroup == :blood"); @SuppressWarnings("unchecked") List<BloodDonor> donors = (List<BloodDonor>) query.execute(state.toLowerCase(), district.toLowerCase(), city.toLowerCase(), bloodGroup.toLowerCase()); This doesnt work as execute method does not support more than 3 parameters. So how to pass more than 3

    Read the article

1