Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using View Accessors Programmatically

vventinSep 9 2010 — edited Sep 13 2010
I am trying to use a view accessor programmatically and am having some success with it but I am running into a problem when trying to apply a view criteria with bind variables.

I have an application scoped application module (SharedAM) with a view object (SharedVO) in which I have created bind variables and a view criteria (SharedVOVC). I did not apply the view criteria to the shared application module because I would like the view to load all of the data at the application level for use by each session. I expect to be able to do this when I reference the view as a view accessor.

I created a session scoped application module (SessionAM) with a view object (SessionTransientVO) which is only made up of a transient attribute. I then was able to create a view accessor SharedAM_SharedVA. The view criteria and bind variables in SharedVO are visible here. Below are the results of testing attaching the view criteria to the view accessor.

I extended the SessionTransientVO and added a method called testVCAccess() to SessionTransientVOImpl.java. I also added the method testVCRowAccess() to SessionTransientVORowImpl.java. In testVCAccess() I create a row programmatically and make a call to testVCRowAccess() to get access to the view accessor. The method testVCAccess() is exposed to the client where I can test it by running the application module, open SessionTransientVO and execute the method.


The code in SessionTransientVOImpl.java:
Row row = createRow();
row.setAttribute("id", 5);
System.out.println("ROW, getattribute(id) " + row.getAttribute("id").toString());
((SessionTrasientVORowImpl)row).testVCRowAccess();
//This successfully calls the method.



The code in SessionTransientVORowImpl.java:

//Create a RowSet of the View Accessor.
RowSet rs = getSharedAM_SharedVA();
//List the contents.
while (rs.hasNext()) {
SharedVORowImpl row = ((SharedVORowImpl )rs.next());
System.out.println("Data: " + row.mydata());
}

(1) Run the above the SessionAM without associating the view criteria with the view accessor I get the list of records as expected.

(2) Associate the view criteria with the view accessor and do not set the bind variable I do not get any records. But I also do not get any error message.

(3) If I associate the view criteria and explicitly set the bind variable I get this error:
(oracle.jbo.SQLStmtException) JBO-27122: SQL error during statement preparation.
Statement: SELECT SessionVO.test, {blah blah full sql statement with no criteria shown.}
----- Level 1: Detail 0 -----
(java.sql.SQLException) Attempt to set a parameter name that does not occur in the SQL: bvTest

(4) If I associate the view criteria and try to programmatically set the bind variable:
RowSet rs = ggetSharedAM_SharedVA();
rs.setNamedWhereClauseParam("bvTest", 1);
rs.executeQuery();

//Create a RowSet of the View Accessor.
RowSet rs = getSharedAM_SharedVA();
//List the contents.
while (rs.hasNext()) {
SharedVORowImpl row = ((SharedVORowImpl )rs.next());
System.out.println("Data: " + row.mydata());
}
This gives me the same error message as (3).

Can someone help me with figuring this out? Seems like this should work.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2010
Added on Sep 9 2010
2 comments
2,095 views