You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Robert Giddings <r....@netcase.co.uk> on 2007/09/18 11:43:45 UTC

getPKEnumerationByQuery()

Hi,

When using the method getPKEnumerationByQuery() I get the following
error:


Caused by: java.util.NoSuchElementException
        at
org.apache.ojb.broker.accesslayer.PkEnumeration.nextElement(Unknown S
ource)
        at
com.netcase.database.DAOService.getIdsByPropertyMatch(DAOService.java
:117)

Has anyone else had any problems using OJB's Enumeration implementation?
As the code that iterates through it is this:

Enumeration pks = broker.getPKEnumerationByQuery(PrimaryKey.class,
query);
			Collection<Integer> ids = new
ArrayList<Integer>();
			while(pks.hasMoreElements()) {
				PrimaryKey pk =
(PrimaryKey)pks.nextElement();
				ids.add(pk.getId());
			}

And I can't see any problem with this code, and so can only conclude
that the hasMoreElements() or nextElement() method was not implemented
correctly.

Thanks,

Robert Giddings


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: getPKEnumerationByQuery()

Posted by Robert Giddings <r....@netcase.co.uk>.
OK, I used getReportQueryIteratorByQuery() and it works.

Thanks,

Rob

-----Original Message-----
From: Armin Waibel [mailto:arminw@apache.org] 
Sent: 18 September 2007 14:07
To: OJB Users List
Subject: Re: getPKEnumerationByQuery()

Hi Robert,

Robert Giddings wrote:
> Hi,
> 
> When using the method getPKEnumerationByQuery() I get the following
> error:
> 
> 
> Caused by: java.util.NoSuchElementException
>         at
> org.apache.ojb.broker.accesslayer.PkEnumeration.nextElement(Unknown S
> ource)
>         at
> com.netcase.database.DAOService.getIdsByPropertyMatch(DAOService.java
> :117)
> 
> Has anyone else had any problems using OJB's Enumeration
implementation?
> As the code that iterates through it is this:
> 
> Enumeration pks = broker.getPKEnumerationByQuery(PrimaryKey.class,
> query);
> 			Collection<Integer> ids = new
> ArrayList<Integer>();
> 			while(pks.hasMoreElements()) {
> 				PrimaryKey pk =
> (PrimaryKey)pks.nextElement();
> 				ids.add(pk.getId());
> 			}
> 
> And I can't see any problem with this code, and so can only conclude
> that the hasMoreElements() or nextElement() method was not implemented
> correctly.

Please check OJB's logging output. Any error log before the 
NoSuchElementException?

By the way, this class is now deprecated because nobody seems to use it.

If you need the PK values to create a user specific PrimaryKey class I 
would recommend (for best performance) a report query to get all PK's.

regards,
Armin

> 
> Thanks,
> 
> Robert Giddings
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org




-- 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.487 / Virus Database: 269.13.22/1013 - Release Date:
17/09/2007 13:29



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: getPKEnumerationByQuery()

Posted by Armin Waibel <ar...@apache.org>.
Hi Robert,

Robert Giddings wrote:
> Hi,
> 
> When using the method getPKEnumerationByQuery() I get the following
> error:
> 
> 
> Caused by: java.util.NoSuchElementException
>         at
> org.apache.ojb.broker.accesslayer.PkEnumeration.nextElement(Unknown S
> ource)
>         at
> com.netcase.database.DAOService.getIdsByPropertyMatch(DAOService.java
> :117)
> 
> Has anyone else had any problems using OJB's Enumeration implementation?
> As the code that iterates through it is this:
> 
> Enumeration pks = broker.getPKEnumerationByQuery(PrimaryKey.class,
> query);
> 			Collection<Integer> ids = new
> ArrayList<Integer>();
> 			while(pks.hasMoreElements()) {
> 				PrimaryKey pk =
> (PrimaryKey)pks.nextElement();
> 				ids.add(pk.getId());
> 			}
> 
> And I can't see any problem with this code, and so can only conclude
> that the hasMoreElements() or nextElement() method was not implemented
> correctly.

Please check OJB's logging output. Any error log before the 
NoSuchElementException?

By the way, this class is now deprecated because nobody seems to use it. 
If you need the PK values to create a user specific PrimaryKey class I 
would recommend (for best performance) a report query to get all PK's.

regards,
Armin

> 
> Thanks,
> 
> Robert Giddings
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org