Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360544 - DescriptorQueryManager is ignored
Summary: DescriptorQueryManager is ignored
Status: CLOSED WORKSFORME
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-11 10:23 EDT by nejgus CLA
Modified: 2022-06-09 10:04 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nejgus CLA 2011-10-11 10:23:19 EDT
Build Identifier: 20110916-0149

Eclipselink 2.3.0
Oracle 10g r2 db

@Override
public void customize(ClassDescriptor descriptor) throws Exception {
	
	descriptor.setReadOnly();
	
	DescriptorQueryManager dqm = descriptor.getDescriptorQueryManager();
	
	StoredFunctionCall sfc = new StoredFunctionCall();
	ReadAllQuery raq = new ReadAllQuery(Table.class);
	sfc.setProcedureName("procedure_name");
	sfc.useUnnamedCursorOutputAsResultSet();
	sfc.setParameters(null);		
	sfc.setResult("FUNCTION_RESULT", Table.class);
	raq.setCall(sfc);
	
	dqm.setReadAllCall(sfc);
	dqm.setReadAllQuery(raq);
	dqm.setReadAllSQLString(null);
	
	descriptor.setQueryManager(dqm);

}

Descriptor is called as expected (I can breakpoint it, also there are errors when you try to do stupid things).

The customized realall operation is ignored. I will get generated select * from table query (Which fails since user doesn't have permissions). Hence it seems crud customization feature which is advertised in documentation is not working at all. Also I could not find one complete example how to implement this.

Have tried querying using EntityManager and eclipselink Sesssion to no avail. I am sure someone from the project could verify this in no time.

Reproducible: Sometimes

Steps to Reproduce:
Try overriding default readall operation to use function. It does not work.
Comment 1 Tom Ware CLA 2011-10-31 13:24:28 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 Tom Ware CLA 2011-12-02 10:27:04 EST
Correcting target milestone to next milestone that will include community-submitted bugs.
Comment 3 Andrei Ilitchev CLA 2012-04-03 11:42:16 EDT
The three DescriptorQueryManager's methods
setReadAllCall, setReadAllQuery and setReadAllSQLString all do the same thing: they set readAllQuery - so you need to use just one of them.

Also you have to set readObject query - for reading of a single object by primary key.

Here's a simple example from Eclipselink tests for class Employee:

StoredProcedureCall readObjectCall = new StoredProcedureCall();
readObjectCall.setProcedureName("Read_Employee");
readObjectCall.addNamedArgument("P_EMP_ID", "EMP_ID");
readObjectCall.useNamedCursorOutputAsResultSet("RESULT_CURSOR");
descriptor.getQueryManager().setReadObjectCall(readObjectCall);

StoredProcedureCall readAllCall = new StoredProcedureCall();
readAllCall.setProcedureName("Read_All_Employees");
readAllCall.useNamedCursorOutputAsResultSet("RESULT_CURSOR");
descriptor.getQueryManager().setReadAllCall(readAllCall);

Where "Read_Employee" and "Read_All_Employees" are stored procedures defined in the Oracle db:

CREATE OR REPLACE  PROCEDURE "READ_EMPLOYEE"  (
	P_EMP_ID NUMBER,
	RESULT_CURSOR OUT CURSOR_TYPE.ANY_CURSOR) AS
BEGIN 
OPEN RESULT_CURSOR FOR Select E.*, S.* from EMPLOYEE E, SALARY S where E.EMP_ID = S.EMP_ID AND E.EMP_ID = P_EMP_ID; 
END;

CREATE OR REPLACE  PROCEDURE "READ_ALL_EMPLOYEES"  (
	RESULT_CURSOR OUT CURSOR_TYPE.ANY_CURSOR) AS
BEGIN 
OPEN RESULT_CURSOR FOR Select E.*, S.* from EMPLOYEE E, SALARY S WHERE E.EMP_ID = S.EMP_ID; 
END;

Class Employee is mapped to two tables EMPLOYEE and SALARY, it's pk is mapped to EMPLOYEE.EMP_ID, SALARY.EMP_ID is a foreign key joining SALARY and EMPLOYEE tables.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:04:37 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink