cancel
Showing results for 
Search instead for 
Did you mean: 

JDO: Query returns too many results.

Former Member
0 Kudos

Hello,

I want to get some DO-Entities from an empty table. When I execute the query I retrieve more than 2 000 000 000 results what is definitly too much for an empty table. The DO has an one-to-many relationship to another class and a many-to-one relationship to another one.

The .map and .jdo files of the class and the classes in relation made accordng to the explanations in the Development Manual chapter "Mapping Persistent Classes to Database Tables" (so including DFG- and embedded- attributes). Enhancing is successfull and the work with the classes that doesn't have relationships also.

The query looks like this:

manager = getPersistenceFactory().getPersistenceManager();

String filter = "version == \"" + version + "\" && postingLevel == \"" + postingLevel +

"\" && closingPeriod == " + closingPeriod + " && bunit== \"" + bunit + "\"";

Query query = manager.newQuery(AD_DO_Protocol.class, filter);

Collection col = (Collection) query.execute();

I also tried to use the extent with the same result.

Any ideas?

Regards,

Jan

Accepted Solutions (0)

Answers (2)

Answers (2)

guru_subramanianb
Active Contributor
0 Kudos

Hi,

Then what do u mean by :-

When I execute the query I retrieve more than 2 000 000 000 results what is definitly too much for an empty table?

U r saying table is empty then how coem u get 2 000 000 000 results or data set?DO u get any SQL exception since ur reading from an empty table?

Rdgs,

Guru

Former Member
0 Kudos

Hi Guru,

"U r saying table is empty then how coem u get 2 000 000 000 results or data set?"

That was exactly what I was wondering about. But I solved the problem. It was my fault. Didn't called retrieveAll on the collection...

Thanks anyway.

Regards

Jan

guru_subramanianb
Active Contributor
0 Kudos

Hi Jan,

You can have "where" constraints in ur query accessing your primary key with foreign key of the other table.

More over if still ur query returns more results,write a java function which flushes the results say only 100 entries per page.

Rdgs,

Guru

Former Member
0 Kudos

Hi Guru,

first of all in that certain method of the DAO I'm not able to use the primary key because I implement a check if an entity with the given attributes allready exists.

Second I don't want (and as I think don't have) to write the mentioned java function for the following reason: There must be max one result for the given query. Thats a constraint implied by our business logic.

In fact at the given moment there must not be a single result because the table IS EMPTY!!!

Any other ideas?

Thx and regards,

Jan