Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Custom SQL for relationship

I see, but I would like to bind this method to the Entity bean not to my stateless bean, which is responsible for other queries.
But maybe I could implement this in entity bean using methods, no queries (so I don't need the entitymanager), but is there an annotation like @Where in hibernate? If there would be like that, then it could be implemented using existing relationships using foreign keys.

On Sat, Nov 27, 2010 at 2:21 PM, cinhtau <cinhtau@xxxxxxxxx> wrote:
Well, you have several issues: I usually use a simple native sql-query calling a procedure or function, e.g.
CREATE OR REPLACE FUNCTION "public"."fx_hello_world" (IN int4, IN int4) RETURNS bool AS
	IF $1 = 1 THEN
SELECT * FROM fx_hello_world(1,1);
SELECT fx_hello_world(1,1);
In Java (in your EJB)
private EntityManager em;

//defined in remote interface
public Company getDefaultCompany(){
    Query q = em.createQuery("SELECT * FROM mystoredprocedure");
    return q.getResultList().get(0);
I don't know why you can't inject your EJB. You should provide a little more information and error logs (remote or local lookup, application server, etc.) Maybe for this issue you should make another post corresponding to the application server mailing list. Hope this helps.
Bálint Kriván wrote:
Hi! Thanks for your reply! I would like to have the getDefaultCompany() method, but I can't code it in the entity bean, that's why I'm asking, if there is a way to query the DB (call the procedure or execute arbitrary queries) from the Entity bean (I can't inject stateless EJB for some reason -> i'm getting null for the injected bean -- What am I doing wrong?).

View this message in context: Re: Custom SQL for relationship

Sent from the EclipseLink - Users mailing list archive at

eclipselink-users mailing list

Kriván Bálint

Back to the top