For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > August 2004 > need help with ejbSelect returning all instances of a field









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need help with ejbSelect returning all instances of a field
Steve Lewis

2004-08-12, 8:57 pm

I am having a lot trouble generating a simple EJB-QL query to return
one attribute from all objects in a table
In the header I say
* @ejb.bean name="MlbTeam"
jndi-name="com.babel17.fbdraft.bean.MlbTeam"
* type="CMP" primkey-field="teamId" schema="MlbTeam"
* cmp-version="2.x" data-source="java:/FBDraft"
*
* @ejb.finder query="SELECT OBJECT(a) FROM MlbTeam as a"
* signature="java.util.Collection findAll()"
The finder works

I have an attribute teamName
I say

/**
* <!-- begin-user-doc -->
* Return the names of all teams -
* Sample home method
* <!-- end-user-doc -->
* @ejb.home-method
*/
public String[] ejbHomeGetTeamNames() throws EJBException
{
try {
Collection items = this.ejbSelectTeamNames();
String[] ret = (String[])items.toArray(new String[0]);
return ret;
}
catch(FinderException ex) {
throw new EJBException(ex);
}
}

/**
*
* @ejb.select
* query="SELECT DISTINCT team.teamName FROM MlbTeam AS team"
* result-type-mapping="Local"
*/
public abstract Collection ejbSelectTeamNames()
throws FinderException;

WHen I run i get an error saying t0_a.teamname does not exist
I am running as a home method
I have also tried
SELECT team.teamName FROM MlbTeam AS team
and
SELECT team.teamName FROM MlbTeam team

What am I doing wrong??????
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com