Using ejbSelect - Weblogic
This is a discussion on Using ejbSelect - Weblogic ; Hi,
I am an novice in J2EE programming. I have started from BEA's medrec sample application
trying to build something mine. I want to count the number of rows in a table.
The finders cannot be used but ejbSelect. The ...
-
Using ejbSelect
Hi,
I am an novice in J2EE programming. I have started from BEA's medrec sample application
trying to build something mine. I want to count the number of rows in a table.
The finders cannot be used but ejbSelect. The problem is the next:
1. How can I use ejbSelect()?
2. How am I supposed to define @ejbgen:select stanza?
3. How am I supposed to define abstract ejbSelect method in the EJB file containing
@ejbgen:select?
4. How am I supposed to call the previous ejbSelect method from my stateless session
bean?
-
Re: Using ejbSelect
Vlado V. wrote:
> Hi,
>
> I am an novice in J2EE programming. I have started from BEA's medrec sample application
> trying to build something mine. I want to count the number of rows in a table.
> The finders cannot be used but ejbSelect. The problem is the next:
>
> 1. How can I use ejbSelect()?
Something like the following:
/**
* ejbgen:select
* ejb-ql="SELECT COUNT(o.iD) FROM BEAN o"
*/
public abstract int ejbSelectQueryTotalCount() throws FinderExcetion;
> 2. How am I supposed to define @ejbgen:select stanza?
> 3. How am I supposed to define abstract ejbSelect method in the EJB file containing
> @ejbgen:select?
Yes...
> 4. How am I supposed to call the previous ejbSelect method from my stateless session
> bean?
Expose in the home interface. Something like the following:
/**
* ejbgen:local-home
*/
public int ejbHomeGetTotalCount() throws FinderException {
return ejbSelectQueryTotalCount();
}
Best regards...
-
One more question for Moe
Hi Moe,
Thanks for your help. I followed your instructions. Things got better. After I
added the next lines:
/**
* @ejbgen:select
* ejb-ql = "SELECT count(o.whoseProId) FROM ToplistEJB AS o
* WHERE o.whoseProId = ?1"
*/
public abstract long ejbSelectQueryNumberOfToplisted(Long pWhoseProId) throws
FinderException;
/**
* @ejbgen:local-home
*/
public long ejbHomeGetNumberOfToplisted(Long pWhoseProId) throws FinderException
{
return ejbSelectQueryNumberOfToplisted(pWhoseProId);
}
I passed the EJB compilation. But, how can I call this ejbSelect from session
bean? I tried using:
long count = toplistHome.ejbHomeGetNumberOfToplisted(pToplist.g etWhoseProId());
in which toplistHome is the variable with Local Home. I got the error message
that ejbHomeGetNumberOfToplisted cannot be resolved.
Please help.
Moe wrote:
>
>
>Vlado V. wrote:
>> Hi,
>>
>> I am an novice in J2EE programming. I have started from BEA's medrec
>sample application
>> trying to build something mine. I want to count the number of rows
>in a table.
>> The finders cannot be used but ejbSelect. The problem is the next:
>>
>> 1. How can I use ejbSelect()?
>
>Something like the following:
>/**
> * ejbgen:select
> * ejb-ql="SELECT COUNT(o.iD) FROM BEAN o"
> */
>public abstract int ejbSelectQueryTotalCount() throws FinderExcetion;
>
>> 2. How am I supposed to define @ejbgen:select stanza?
>> 3. How am I supposed to define abstract ejbSelect method in the EJB
>file containing
>> @ejbgen:select?
>
>Yes...
>
>> 4. How am I supposed to call the previous ejbSelect method from my
>stateless session
>> bean?
>
>Expose in the home interface. Something like the following:
>/**
> * ejbgen:local-home
> */
>public int ejbHomeGetTotalCount() throws FinderException {
> return ejbSelectQueryTotalCount();
>}
>
>Best regards...
>
-
Re: One more question for Moe
Try something like the following:
toplistHome.getNumberOfToplisted(...)
When calling the home method we can omit ejbHome on the client side...
Vlado V. wrote:
> Hi Moe,
>
> Thanks for your help. I followed your instructions. Things got better. After I
> added the next lines:
> /**
> * @ejbgen:select
> * ejb-ql = "SELECT count(o.whoseProId) FROM ToplistEJB AS o
> * WHERE o.whoseProId = ?1"
> */
> public abstract long ejbSelectQueryNumberOfToplisted(Long pWhoseProId) throws
> FinderException;
>
> /**
> * @ejbgen:local-home
> */
> public long ejbHomeGetNumberOfToplisted(Long pWhoseProId) throws FinderException
> {
> return ejbSelectQueryNumberOfToplisted(pWhoseProId);
> }
>
> I passed the EJB compilation. But, how can I call this ejbSelect from session
> bean? I tried using:
>
> long count = toplistHome.ejbHomeGetNumberOfToplisted(pToplist.g etWhoseProId());
>
> in which toplistHome is the variable with Local Home. I got the error message
> that ejbHomeGetNumberOfToplisted cannot be resolved.
>
> Please help.
>
>
> Moe wrote:
>
>>
>>Vlado V. wrote:
>>
>>>Hi,
>>>
>>>I am an novice in J2EE programming. I have started from BEA's medrec
>>
>>sample application
>>
>>>trying to build something mine. I want to count the number of rows
>>
>>in a table.
>>
>>>The finders cannot be used but ejbSelect. The problem is the next:
>>>
>>>1. How can I use ejbSelect()?
>>
>>Something like the following:
>>/**
>> * ejbgen:select
>> * ejb-ql="SELECT COUNT(o.iD) FROM BEAN o"
>> */
>>public abstract int ejbSelectQueryTotalCount() throws FinderExcetion;
>>
>>
>>>2. How am I supposed to define @ejbgen:select stanza?
>>>3. How am I supposed to define abstract ejbSelect method in the EJB
>>
>>file containing
>>
>>>@ejbgen:select?
>>
>>Yes...
>>
>>
>>>4. How am I supposed to call the previous ejbSelect method from my
>>
>>stateless session
>>
>>>bean?
>>
>>Expose in the home interface. Something like the following:
>>/**
>> * ejbgen:local-home
>> */
>>public int ejbHomeGetTotalCount() throws FinderException {
>> return ejbSelectQueryTotalCount();
>>}
>>
>>Best regards...
>>
>
>
-
Re: One more question for Moe
Hi Moe,
I defined ejbHome like:
/**
* @ejbgen:local-home-method
*/
public long ejbHomeGetNumberOfToplisted(Long pWhoseProId) throws FinderException
{
return ejbSelectQueryNumberOfToplisted(pWhoseProId);
}
and got the result. Thank you very much for your help.
Moe wrote:
>Try something like the following:
>
>toplistHome.getNumberOfToplisted(...)
>
>When calling the home method we can omit ejbHome on the client side...
>
>Vlado V. wrote:
>> Hi Moe,
>>
>> Thanks for your help. I followed your instructions. Things got better.
>After I
>> added the next lines:
>> /**
>> * @ejbgen:select
>> * ejb-ql = "SELECT count(o.whoseProId) FROM ToplistEJB AS o
>> * WHERE o.whoseProId = ?1"
>> */
>> public abstract long ejbSelectQueryNumberOfToplisted(Long pWhoseProId)
>throws
>> FinderException;
>>
>> /**
>> * @ejbgen:local-home
>> */
>> public long ejbHomeGetNumberOfToplisted(Long pWhoseProId) throws FinderException
>> {
>> return ejbSelectQueryNumberOfToplisted(pWhoseProId);
>> }
>>
>> I passed the EJB compilation. But, how can I call this ejbSelect from
>session
>> bean? I tried using:
>>
>> long count = toplistHome.ejbHomeGetNumberOfToplisted(pToplist.g etWhoseProId());
>>
>> in which toplistHome is the variable with Local Home. I got the error
>message
>> that ejbHomeGetNumberOfToplisted cannot be resolved.
>>
>> Please help.
>>
>>
>> Moe wrote:
>>
>>>
>>>Vlado V. wrote:
>>>
>>>>Hi,
>>>>
>>>>I am an novice in J2EE programming. I have started from BEA's medrec
>>>
>>>sample application
>>>
>>>>trying to build something mine. I want to count the number of rows
>>>
>>>in a table.
>>>
>>>>The finders cannot be used but ejbSelect. The problem is the next:
>>>>
>>>>1. How can I use ejbSelect()?
>>>
>>>Something like the following:
>>>/**
>>> * ejbgen:select
>>> * ejb-ql="SELECT COUNT(o.iD) FROM BEAN o"
>>> */
>>>public abstract int ejbSelectQueryTotalCount() throws FinderExcetion;
>>>
>>>
>>>>2. How am I supposed to define @ejbgen:select stanza?
>>>>3. How am I supposed to define abstract ejbSelect method in the EJB
>>>
>>>file containing
>>>
>>>>@ejbgen:select?
>>>
>>>Yes...
>>>
>>>
>>>>4. How am I supposed to call the previous ejbSelect method from my
>>>
>>>stateless session
>>>
>>>>bean?
>>>
>>>Expose in the home interface. Something like the following:
>>>/**
>>> * ejbgen:local-home
>>> */
>>>public int ejbHomeGetTotalCount() throws FinderException {
>>> return ejbSelectQueryTotalCount();
>>>}
>>>
>>>Best regards...
>>>
>>
>>