Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » BUG : postgresql @NamedStoredProcedureQuery call
BUG : postgresql @NamedStoredProcedureQuery call [message #1120996] Mon, 30 September 2013 06:50 Go to next message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 13
Registered: May 2013
Junior Member
I created a simple function in postgresql

  CREATE OR REPLACE FUNCTION simpletest()
  RETURNS bigint AS
$BODY$
BEGIN
   
   return 10;
END;
$BODY$
  LANGUAGE plpgsql


when I try to run it with eclipse link I get this exception

ERROR: syntax error at or near ")"
  Position: 20
Error Code: 0
Call: EXECUTE simpletest()
Query: DataReadQuery(name="simpletest" )


I assume this is eclipselink bug and this is how I define and run the function.

@NamedStoredProcedureQuery(name="simpletest", procedureName="simpletest")
public class Student


public void exec()
    {
        Query createNamedQuery = entityManager.createNamedQuery("simpletest");
        System.out.println(createNamedQuery.getResultList());
        
    }


is this a bug ?
Re: BUG : postgresql @NamedStoredProcedureQuery call [message #1121017 is a reply to message #1120996] Mon, 30 September 2013 07:18 Go to previous messageGo to next message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 13
Registered: May 2013
Junior Member
I realized this is related to org.eclipse.persistence.platform.database.PostgreSQLPlatform

public String getProcedureCallHeader() {
        return "EXECUTE ";
    }

based on http://www.postgresql.org/docs/8.0/static/plpgsql.html. it should return "SELECT " not EXECUTE
Re: BUG : postgresql @NamedStoredProcedureQuery call [message #1121392 is a reply to message #1121017] Mon, 30 September 2013 15:20 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
How have you set the PostgreSQLPlatform so that it is used? The PostgreSQLPlatform class overrides the buildProcedureCallString() method, so getProcedureCallHeader() on the DatabasePlatform class shouldn't get used.

Try setting the eclipselink.target-database property to "PostgreSQL" if you haven't already:
http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_target_database.htm

Best Regards,
Chris
Re: BUG : postgresql @NamedStoredProcedureQuery call [message #1124425 is a reply to message #1121392] Thu, 03 October 2013 14:23 Go to previous messageGo to next message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 13
Registered: May 2013
Junior Member
thank you Chris,

if you mean
org.eclipse.persistence.platform.database.PostgreSQLPlatform

yes I have used it as target database and it is "EXECUTE" in getProcedureCallHeader() method not SELECT anyway Do you know why direction is deprecated ?

I have a function with two input arguments and two output arguments which is defined as follow

@NamedStoredProcedureQuery(name = DocumentAccess.CONTAINS_DOC_BY_ANOTHER_OWNER, procedureName = "contains_doc_by_another_owner", parameters = {
                @StoredProcedureParameter(queryParameter = "commaSeparatedIds", type = String.class, direction=Direction.IN),
                @StoredProcedureParameter(queryParameter = "uid", type = Long.class, direction=Direction.IN), 
                @StoredProcedureParameter(queryParameter = "has_another_owner", type = Boolean.class, direction= Direction.OUT),
                @StoredProcedureParameter(queryParameter = "doc_id", type = Long.class, direction= Direction.OUT)}, resultSetMappings = { DocumentAccess.CONTAINS_DOC_BY_ANOTHER_OWNER }),


but the query is select contains_doc_by_another_owner(?,?) . it should be

select has_another_owner, doc_id from contains_doc_by_another_owner(?,?)
Re: BUG : postgresql @NamedStoredProcedureQuery call [message #1125564 is a reply to message #1124425] Fri, 04 October 2013 16:54 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1034
Registered: July 2009
Senior Member
Looks like 'direction' was deprecated and replaced with 'mode' to be inline with javax.persistence.StoredProcedureParameter from the JPA 2.1 specification.

I'm not sure why it is calling execute instead of select. Please provide the full stack from the error as that might give an indication as to why the wrong code path is being used.

Re: BUG : postgresql @NamedStoredProcedureQuery call [message #1126061 is a reply to message #1125564] Sat, 05 October 2013 05:26 Go to previous message
Omid Pourhadi is currently offline Omid Pourhadi
Messages: 13
Registered: May 2013
Junior Member
I had it fixed by extending Postgresql platform

public class PostgresqlPlatform extends PostgreSQLPlatform
{

    @Override
    public String getProcedureCallHeader()
    {
        return "SELECT * FROM ";
    }

    @Override
    public boolean shouldPrintStoredProcedureArgumentNameInCall()
    {
        return false;
    }

}

Previous Topic:Reverse Engineering Legacy Database
Next Topic:second level cache without persistence.xml
Goto Forum:
  


Current Time: Wed Oct 22 22:41:14 GMT 2014

Powered by FUDForum. Page generated in 0.10550 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software