Use of JAX RPC Weblogic Callback Capability - weblogic.developer.interest.webservices.general(Archived)

Just walking through the Callback example in the bea documentation at:
http://edocs.bea.com/wls/docs100/webserv_adv/callback.html#wp259721
But I can't seem to get the example to build properly, anyone else have troubles with this?
Anyone else using callbacks at all?
Code trying to build:
= = = = = = = = = = = = = = = = = =
package jsip.jaxrpc.services;
import weblogic.jws.WLHttpTransport;
import weblogic.jws.*;
import weblogic.wsee.jws.CallbackInterface;
import javax.jws.WebMethod;
import javax.jws.WebService;
#WebService(name="CallbackPortType",
serviceName="WhereIsWaldo",
targetNamespace="http://examples.org/")
          
#WLHttpTransport(contextPath="callback",
serviceUri="WhereIsWaldo",
portName="WhereIsWaldo")
          
public class JaxrpcAsyncReqRes
{
#Callback
CallbackInterface callback;
     
#WebMethod
public void callbackOperation (String message)
{       
callback.callbackOperation (message);
}
}
Error produced:
= = = = = = = = = = == = =
[jwsc] [ERROR] - weblogic.jws.CallbackService Annotation must be present on weblogic.wsee.jws.CallbackInterface.
[jwsc] [ERROR] - The annotation weblogic.jws.Exclude is not allowed on callback interface weblogic.wsee.jws.CallbackInterface.
Error message when building:

Related

send sms request cannot be processed after calling sendSms webservice.

Hi All,
I have created one test client that gets the session ID from oracle gatekeeper session webservice and then I am calling the sendSms webservice to send the SMS.
My Test Client is:
TestClientt.java gets the session ID successfully
--------------------------------------------------------------------------------
package test;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
public class TestClientt {
public static void main(String[] args) {
try {
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPHeader header = soapEnvelope.getHeader();
SOAPBody sb = message.getSOAPBody();
QName bodyName = new QName(
"http://www.bea.com/wsdl/wlcp/wlng/session_manager/service",
"getSession", "ser");
SOAPBodyElement bodyElement = sb.addBodyElement(bodyName);
SOAPElement security =
header
.addChildElement(
"Security",
"wssp",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
SOAPElement usernameToken =
security.addChildElement("UsernameToken", "wssp");
usernameToken
.addAttribute(
new QName("xmlns:wsp"),
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
SOAPElement username =
usernameToken.addChildElement("Username", "wssp");
usernameToken
.setAttribute(
"Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken");
username.addTextNode("sdpai");
SOAPElement password =
usernameToken.addChildElement("Password", "wssp");
password
.setAttribute(
"Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
password.addTextNode("sdp");
URL endpoint = new URL(
"http://localhost:8001/session_manager/SessionManager");
System.out.println("\n Soap Request:\n");
message.writeTo(System.out);
System.out.println();
SOAPMessage response = connection.call(message, endpoint);
System.out.println("\n Soap Response:\n");
response.writeTo(System.out);
String resp = null;
resp = response.getSOAPBody().getLastChild().getLastChild()
.toString();
System.out.println();
connection.close();
System.out.println("Session ID" + resp);
int start = resp.indexOf("app:");
int end = resp.indexOf("</ser:getSessionReturn>");
String sessionID = resp.substring(start, end);
System.out.println("Session ID" + sessionID);
test3 test = new test3();
test.responseSms(sessionID);
} catch (Exception e) {
e.printStackTrace();
}
}
}
test3.java http://Called by TestClientt.java after and passing sessionID to it
--------------------------------------------------------------------------------
package test;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
public class test3 {
public void responseSms(String sessionID) {
try {
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
SOAPConnection connection = sfc.createConnection();
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPHeader header = soapEnvelope.getHeader();
SOAPBody sb = message.getSOAPBody();
QName bodyName1 = new QName(
"http://www.csapi.org/schema/parlayx/sms/send/v2_2/local",
"sendSms");
SOAPBodyElement bodyElement = sb.addBodyElement(bodyName1);
QName qn = new QName("addresses");
SOAPElement selem3 = bodyElement.addChildElement(qn);
selem3.addTextNode("tel:1234");
QName qn1 = new QName("message");
SOAPElement selem4 = bodyElement.addChildElement(qn1);
selem4.addTextNode("This is a Test Message From Naveen");
SOAPElement security =
header
.addChildElement(
"Security",
"wssp",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
SOAPElement usernameToken =
security.addChildElement("UsernameToken", "wssp");
usernameToken
.addAttribute(
new QName("xmlns:wsp"),
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
SOAPElement username =
usernameToken.addChildElement("Username", "wssp");
usernameToken
.setAttribute(
"Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken");
username.addTextNode("sdpai");
SOAPElement password =
usernameToken.addChildElement("Password", "wssp");
password
.setAttribute(
"Type",
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText");
password.addTextNode("sdp");
QName headerName1 = new QName("Session");
SOAPHeaderElement headerElement2 = header
.addHeaderElement(headerName1);
QName qn4 = new QName("SessionId");
SOAPElement selem6 = headerElement2.addChildElement(qn4);
selem6.addTextNode(sessionID);
System.out.println("\n Soap Request:\n");
message.writeTo(System.out);
System.out.println();
URL endpoint = new URL(
"http://localhost:8001/parlayx21/sms/SendSms");
SOAPMessage response = connection.call(message, endpoint);
System.out.println("\n Soap Response:\n");
response.writeTo(System.out);
connection.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I am getting the error at line:
SOAPMessage response = connection.call(message, endpoint);
and the error is:
javax.xml.soap.SOAPException:
at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:194)
at org.apache.axis2.saaj.SOAPConnectionImpl.call(SOAPConnectionImpl.java:130)
at test.test3.responseSms(test3.java:103)
at test.TestClientt.main(TestClientt.java:100)
Caused by: org.apache.axis2.AxisFault:
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
in OCSG trace logs, it shows:
10 Jun 2009 18:05:00,455 [ WARN com.bea.wlcp.wlng.util.EJBHelper - Failed to process request
com.bea.wlcp.wlng.api.plugin.DenyPluginException: org.csapi.schema.parlayx.common.v2_1.ServiceException
at com.bea.wlcp.wlng.interceptor.ValidateRequestUsingRequestFactory.invoke(ValidateRequestUsingRequestFactory.java:38)
at com.bea.wlcp.wlng.interceptor.ContextImpl.invokeNext(ContextImpl.java:87)
at com.bea.wlcp.wlng.interceptor.EnforceSpAppBudget.invoke(EnforceSpAppBudget.java:70)
at com.bea.wlcp.wlng.interceptor.ContextImpl.invokeNext(ContextImpl.java:87)
************************************
Please let me know what the issue is. To my surprise the soap message which I am getting thru test3.java is successfully returning the response in SOAP UI Tool and I am able to receive the message but its not working thru my client program. SOAP meesage is correct but something is wrong somewhere. Please let me know where I am missing or what wrong I am doing??????

Problem calling oracle SP from Java

Hi I am trying to call an oracle SP from Java program and getting the error code 17060. Below is my code: Oracle SP: ---------------- create or replace type item as object (itemnumber varchar2(9),itemdesc varchar2(35)); create or replace type uom as object (prodUOM varchar2(18), ratioDen NUMBER(1)); CREATE OR REPLACE TYPE uom_Arr aS VARRAY(100) OF uom; create or replace package test_pkg_xml is procedure test_sp_xml (item_rec item, uom_tbl uom_arr); end test_pkg_xml; / create or replace package body test_pkg_xml is procedure test_sp_xml (item_rec item, uom_tbl uom_arr) is begin null; end; end test_pkg_xml; / --------------- Java Code --------------- public class item implements SQLData { private String sql_type; public String itemnumber ; public String itemdesc ; public String getSQLTypeName() throws SQLException { return sql_type; } public void readSQL(SQLInput stream, String typeName)throws SQLException { sql_type = typeName; itemnumber = stream.readString(); itemdesc = stream.readString(); } public void writeSQL(SQLOutput stream) throws SQLException { System.out.println("in write sql"); stream.writeString (itemnumber); stream.writeString (itemdesc); } } package com.tgt.dstb.dwm.dstbtowm.dao; import javax.xml.parsers.*; import org.w3c.dom.*; import java.sql.Connection; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Types; import java.sql.SQLException; import java.util.Map; import java.util.Hashtable; ----- public class TestDOM { public static void test(Connection conn) throws Exception { item obj1 = new item(); Obj2 obj2 = new Obj2(); Obj2[] obj3 = {new Obj2(), new Obj2()}; String sql = "call " + "test_pkg_xml.test_sp_xml(?,?)"; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.parse( "item.xml" ); Element itemMaster = document.getDocumentElement(); NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber"); NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc"); System.out.println("Item = "); String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" ); String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" ); obj1.itemnumber = itmname; obj1.itemdesc = itmdesc; System.out.println("itmname = " + obj1.itemnumber ); System.out.println("itmdesc = " + obj1.itemdesc ); NodeList uoms = itemMaster.getElementsByTagName("uoms"); NodeList uom = itemMaster.getElementsByTagName("uom"); System.out.println("uom = "); for( int i=0; i<uom.getLength(); i++ ) { String itmprodUOM = DOMUtil.getSimpleElementText( (Element)uom.item(i),"prodUOM" ); obj3.prodUOM = itmprodUOM; String itmratioDen = DOMUtil.getSimpleElementText( (Element)uom.item(i), "ratioDen" ); obj3[i].ratioDen = itmratioDen; System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" ); } try { Hashtable map = new Hashtable(); map.put ("item", Class.forName ("com.tgt.dstb.dwm.dstbtowm.dao.item")); conn.setTypeMap(map); System.out.println("here 11111 "); CallableStatement stmt = conn.prepareCall("call test_pkg_xml.test_sp_xml(?,?)"); System.out.println("here 2 "); stmt.setObject(1,obj1); System.out.println("here 3 "); stmt.setObject(2,obj3); System.out.println("here 4 "); stmt.execute(); System.out.println("here 5 "); }catch (SQLException e) { System.out.println("exception :"+e.getErrorCode()); } } } Can you please point out where I might be going wrong with the code? Any help would be greatly appreciated. PS : I am getting the error 17060 after the stmt : System.out.println("here 2 "); Thanks, Nitin 
Nitin,
I don't use type maps, like you have in the code you posted, I use STRUCT and ARRAY. Works well for me. You can find more details by searching this forum's archives for the terms STRUCT and ARRAY.
Good Luck,
Avi. 
Avi, I changed my code to:
package com.tgt.dstb.dwm.dstbtowm.dao;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.sql.Connection;
//import java.sql.CallableStatement;
import java.sql.*;
//import java.util.Map;
//import java.util.Hashtable;
import oracle.sql.ArrayDescriptor;
import oracle.sql.*;
import oracle.jdbc.*;
public class TestDOM
{
public static void test(Connection conn) throws Exception
{
     item obj1 = new item();
     Obj2 obj2 = new Obj2();
     
     Obj2[] obj3 = {new Obj2(), new Obj2()};
     
     String sql = " call test_pkg_xml.test_sp_xml(?,?)";
     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse( "item.xml" );
Element itemMaster = document.getDocumentElement();
NodeList itemNumber = itemMaster.getElementsByTagName("itemNumber");
NodeList itemDesc = itemMaster.getElementsByTagName("itemDesc");
System.out.println("Item = ");
String itmname = DOMUtil.getSimpleElementText( itemMaster, "itemNumber" );
String itmdesc = DOMUtil.getSimpleElementText( itemMaster, "itemDesc" );
obj1.itemnumber = itmname;
obj1.itemdesc = itmdesc;
System.out.println("itmname = " + obj1.itemnumber );
System.out.println("itmdesc = " + obj1.itemdesc );
NodeList uoms = itemMaster.getElementsByTagName("uoms");
NodeList uom = itemMaster.getElementsByTagName("uom");
System.out.println("uom = ");
for( int i=0; i<uom.getLength(); i++ ) {
String itmprodUOM = DOMUtil.getSimpleElementText(
(Element)uom.item(i),"prodUOM" );
obj3.prodUOM = itmprodUOM;
String itmratioDen = DOMUtil.getSimpleElementText(
(Element)uom.item(i), "ratioDen" );
obj3[i].ratioDen = Integer.parseInt(itmratioDen);
System.out.println( " "+ itmprodUOM +" ("+itmratioDen+")" );
}
try
     {
System.out.println("here 1 ");
OracleCallableStatement stmt = (OracleCallableStatement)
conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");
System.out.println("here 1.1 ");
System.out.println("here 1.2 ");
ArrayDescriptor desc1 = ArrayDescriptor.createDescriptor("UOM_ARR", conn);
     ARRAY array_to_pass1 = new ARRAY(desc1, conn, obj3);
System.out.println("here 2 ");
stmt.setObject(1,obj1,OracleTypes.STRUCT);
System.out.println("here 3 ");
stmt.setArray(2,array_to_pass1);
System.out.println("here 4 ");
stmt.execute();
System.out.println("here 5 ");
     }catch (Exception e)
     {
          e.printStackTrace();
     }
}
}
However, now I the code is printing
"here 1 "
and then giving
"[1/4/07 11:37:28:133 CST] 00000036 SystemErr R java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement"
at "OracleCallableStatement stmt = (OracleCallableStatement)
conn.prepareCall("BEGIN test_pkg_xml.test_sp_xml(?,?); END;");"
statement.
I am using Rational App Developer Version 6.0.1 and getting a connection using
the below code:
--------------
          DataSource     dataSource=null ;
          Context jndiContext = new InitialContext();
          dataSource =
(DataSource)jndiContext.lookup("java:comp/env/jdbc/DWM3DDS");
          Connection wsConn = dataSource.getConnection();
--------------
Looks like this exception occurs when I am casting java.sql.Connection object to OracleCallableStatement. Do you have any idea why this might be occuring? Have you encountered this kind of a problem?
Thanks,
Nitin 
Hi,
I have a complete and working example using SQLData and type map, as you did in chapter 3 of my book (look for Mapping SQLJ Object Types).
Are you confident that the JNDI lookup works in the database?
Also, not sure you can get an OracleCallableStatement object from a java.sql.Connection object (rather from an OracleConnection object).
Kuassi
- blog http://db360.blogspot.com/
- book http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html 
Nitin,
As Kuassi says, you need an "OracleConnection" object in order to use an "OracleCallableStatement". Indeed, you need an "OracleConnection" in order to use STRUCT and ARRAY.
Looks like you are using WebSphere. I believe there is a way to extract an "OracleConnection" from a database "Connection" obtained via WebSphere -- but I don't know how, since I don't use WebSphere.
A tiny detail you failed to mention -- that you are using WebSphere -- completely explains why you are having trouble.
Good Luck,
Avi. 
Hi, Avi.
Could you give me some samples how to use STRUCT in the same case with Nitin, but use Weblogic not WebSphere.
Thank you. 
No. Sorry :-(
Good Luck,
Avi.

Sun implementation and WebLogic

Hi,
I have no problems to connect to my web services with "rpc" style in WebLogic
8.1 with any types of client applications - generated client classes, WSDL, etc.
But if only I try to use Sun's framework:
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
SOAPFactory soapFactory = SOAPFactory.newInstance();
..
etc.
I get an error:
javax.xml.soap.SOAPException: Failed to send message: java.io.IOException: Received
a response from url: http://localhost:7001/rpc/javaclass/XXX?WSDL which did not
have a valid SOAP content-type: null.
At the same time I get an output on the server side:
[0][][null]
[0][xml][http://www.w3.org/XML/1998/namespace]
[1][env][http://schemas.xmlsoap.org/soap/envelope/]
[1][xsi][http://www.w3.org/2001/XMLSchema-instance]
[1][soapenc][http://schemas.xmlsoap.org/soap/encoding/]
[1][xsd][http://www.w3.org/2001/XMLSchema]
I'll appreciate any suggestion.
Regards
Andrei
Hi,
It looks like I found decision, so just in case:
import java.util.*;
import java.io.*;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.*;
import org.apache.log4j.*;
import junit.framework.*;
import javax.xml.soap.*;
..
     public void testHelloWorldSoap()
     throws Exception{
          String logStr= "testHelloWorldSoap() : ";
          log.debug(logStr + "start");
          try{
               SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
               SOAPConnection connection = soapConnectionFactory.createConnection();
               SOAPFactory soapFactory = SOAPFactory.newInstance();
     
               MessageFactory factory = MessageFactory.newInstance();
               SOAPMessage message = factory.createMessage();
     
               SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
               SOAPHeader header = envelope.getHeader();
               SOAPBody body = envelope. getBody();
               envelope.addNamespaceDeclaration("m", "http://www.shedko.com/webservices/javaclass");
               body.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/");
               Name bodyName = envelope.createName(
                    "sayHello", "m",
                    "http://www.shedko.com/webservices/javaclass");
               SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
     
               Name intValName = envelope.createName("intVal");
               SOAPElement intValPar = bodyElement.addChildElement(intValName);
               intValPar.addTextNode("1");
     
               Name stringName = envelope.createName("string");
               SOAPElement stringPar = bodyElement.addChildElement(stringName);
               stringPar.addTextNode("Hello World!!!");
               message.writeTo(System.out);
               log.debug("");
               URL endpoint = new URL ("http://localhost:7001/rpc/javaclass/HelloWorld?WSDL");
               SOAPMessage response = connection.call(message, endpoint);
               response.writeTo(System.out);
               log.debug("");
     
               connection.close();
     
               SOAPBody soapBody = response.getSOAPPart().getEnvelope().getBody();
               bodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
               SOAPElement soapElement = (SOAPElement) bodyElement.getChildElements().next();
               String responseText = soapElement.getValue();
               log.debug("The response is : " + responseText);
          } catch (Exception e){
               log.error(e);
               fail();
          }
          log.debug(logStr + "end");
     }

TransformerConfigurationException with Xalan 2.1, WL 6.0 sp2

On Solaris, jdk 1.3:
I'm using:
public void transform( AdviewsXMLDocument xmlDoc, PrintWriter outWriter )
throws CorporateException {
String media= null , title = null, charset = null;
try{
TransformerFactory tFactory = TransformerFactory.newInstance();
StringReader xmlReader = new StringReader( xmlDoc.toString() );
StreamSource streamSource = new StreamSource( xmlReader ) ;
Source stylesheet = tFactory.getAssociatedStylesheet( streamSource,
media, title, charset);
Transformer transformer = tFactory.newTransformer(stylesheet);
StreamResult streamResult = new StreamResult( outWriter ) ;
transformer.transform( streamSource , streamResult ) ;
} catch (Exception ex ) {
throw new CorporateException(
"XSLT transform exception: " + ex.toString(),
CorporateException.ERROR );
}
}
but getting:
XSLT transform exception:
javax.xml.transform.TransformerConfigurationException:
getAssociatedStylesheets failed
The startup script does set the Transformer property:
.. -Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.Trans
formerFactoryImpl ...
The xml document ( inherited from the ecs XMLDocument ) passed has:
<?xml-stylesheet href="style/portal.xsl" type="text/xsl"?>
and it parses successfully when used against the command line of Xalan.
( The "style" directory is directly under the application's root directory
within the war within the ear ).
Apparently the org.apache.xalan.processor.TransformerFactoryImpl is throwing
a org.xml.sax.SAXException, which then produces the
"getAssociatedStylesheets failed", but why?
Any ideas?
Charlie Crook
Nielsen Media Research

wrong generated query - one to many relationship

Hi All:
I have a class, GroupBookingPolicy. It has one-many relationship with groupBookingAlertCollection.
Below toplink code generates a query
-------------------------------------------
SELECT
DISTINCT t0.CONCURRENCYCOUNTER,
t0.RS_GBP_ID,
t0.LASTMODIFIEDBY,
t0.CREATEDBY,
t0.LASTMODIFIEDDATE,
t0.GROUPBOOKINGPOLICYID,
t0.CREATEDDATE,
t0.DELFLAG,
t0.CS_SC_ID
FROM
RS_GROUPBOOKINGPOLICY t0,
RS_GROUPBOOKINGALERT t2,
RS_GROUPBOOKINGALERT t1
WHERE
((((t0.CREATEDBY = 'Creator') AND
(t1.ALERTPURPOSE = 'dfgdfg')) AND
(t2.ALERTACTION = 'dfgdfg')) AND
((t2.RS_GBP_ID = t0.RS_GBP_ID) AND
(t1.RS_GBP_ID = t0.RS_GBP_ID)))
------------------------------------------
Actually I want the query which get generated to look like as below
SELECT
DISTINCT t0.CONCURRENCYCOUNTER,
t0.RS_GBP_ID,
t0.LASTMODIFIEDBY,
t0.CREATEDBY,
t0.LASTMODIFIEDDATE,
t0.GROUPBOOKINGPOLICYID,
t0.CREATEDDATE,
t0.DELFLAG,
t0.CS_SC_ID
FROM
RS_GROUPBOOKINGPOLICY t0,
RS_GROUPBOOKINGALERT t1
WHERE
((((t0.CREATEDBY = 'Creator') AND
(t1.ALERTPURPOSE = 'dfgdfg')) AND
(t1.ALERTACTION = 'dfgdfg')) AND
(t1.RS_GBP_ID = t0.RS_GBP_ID)))
-------------------------------------
Toplink Code :
This is test class.
import oracle.toplink.sessions.*;
import oracle.toplink.tools.sessionmanagement.SessionManager;
import oracle.toplink.threetier.*;
import oracle.toplink.expressions.*;
import oracle.toplink.sessionbroker.SessionBroker;
import java.util.*;
public class ToplinkServerLoader
{
private static ToplinkServerLoader singleObj = null;
private static Server toplinkServer = null;
private ToplinkServerLoader()
{}
public static ToplinkServerLoader getInstance()
{
if(singleObj == null)
{
singleObj = new ToplinkServerLoader();
}
return singleObj ;
}
public Server getServer(String fileName)
{
java.lang.ClassLoader classloader = this.getClass().getClassLoader();
SessionManager sessionManager = SessionManager.getManager();
Server mServer = (Server)sessionManager.getSession(fileName, classloader);
return mServer;
}
public Server getServer()
{
if( toplinkServer == null)
{
SessionManager sessionManager = SessionManager.getManager();
toplinkServer = (Server)sessionManager.getSession("TLResrPolicies");
}
return toplinkServer;
}
public static void main (String[] args)
{
Server toplinkServer = ToplinkServerLoader.getInstance().getServer();;
ClientSession toplinkClientSession = toplinkServer.acquireClientSession();
ExpressionBuilder eb = new ExpressionBuilder();
Expression e2 = eb.get("createdBy").equal("Creator");
Expression e1 = eb.anyOf("groupBookingAlertCollection").get("alertPurpose").equal("dfgdfg");
Expression e3 = eb.anyOf("groupBookingAlertCollection").get("alertAction").equal("dfgdfg");
Vector v =
toplinkClientSession.readAllObjects(GroupBookingPolicy.class,e2.and(e1).and(e3)) ;
if(v!= null)
{
for(int i = 0; i<v.size() ; i++)
{
GroupBookingPolicy groupBookingPolicy = (GroupBookingPolicy)v.get(i) ;
System.out.println(groupBookingPolicy.getGroupBookingPolicyID());
}
}
}
}
-------------------
Thanks,
Viral 
Viral,
TopLink's expressions are 'nodal' and follow java's attribute navigation pattern. Try changing your expression to the following:
//start
ExpressionBuilder eb = new ExpressionBuilder();
Expression e2 = eb.get("createdBy").equal("Creator");
//isolate the collection elements
Expression e4 = eb.anyOf("groupBookingAlertCollection");
//check that the elements of the above collection both requirements
Expression e1 = e4.get("alertPurpose").equal("dfgdfg");
Expression e3 = e4.get("alertAction").equal("dfgdfg");
toplinkClientSession.readAllObjects(GroupBookingPolicy.class,e2.and(e4.and(e3))) ;
//end
In your expression because expressions 1 and 3 were not sharing the same expression base TopLink reads that as the checks being on elements from separate collections.
--Gordon
Thanks Gordan.
I have tried as per your suggestion and it works.
Regards,
Viral

Categories

Resources