Query on interface concept

Class A{}
Interface I{}
public Class B
Public static void main ( String[] xx)
A a = new A();
I ii = a; // it doesn?t ..
I i = (I) a ; // it works WHY?
// why this code compiles ?

newbie_007 wrote:
Class A{}
Interface I{}
public Class B
Public static void main ( String[] xx)
A a = new A();
I ii = a; // it doesn?t ..
I i = (I) a ; // it works WHY?
// why this code compiles ?public class B
public static void main ( String[] xx)
A a = new A();
A ii = a; // it doesn?t ..
I i = (I) a ; // it works WHY?
class A{}
interface I{}
but this compiles and I wonder too. But when I run it, it throus
Exception in thread "main" java.lang.ClassCastException: A cannot be cast to I
     at B.main(B.java:15)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
interesting.
Edited by: Tiko_dev on Apr 30, 2009 7:11 AM

Similar Messages

  • Query on interface

    I am getting "The parameter name [startDate] in the query's selection criteria does not match any parameter name defined in the query" error when querying on interface using TopLink 11g (11.1.3). The interface is implemented by many classes MyImplementationClass being one of them. The query works in TopLink 10g. Is this a bug in 11g? Thanks.
    Here is my code:
    +// subquery+
    ExpressionBuilder subqueryBuilder = new ExpressionBuilder();
    ReportQuery subQuery = new ReportQuery(MySubQueryClass.class, subqueryBuilder);
    +// Main read query+
    ReadAllQuery namedQuery1 = new ReadAllQuery(MyInterface.class);
    ExpressionBuilder expBuilder1 = namedQuery1.getExpressionBuilder();
    subQuery.addAttribute("primaryKey");
    subQuery.setSelectionCriteria(
    subqueryBuilder.get("operationDate").between(
    subqueryBuilder.getParameter("startDate"),
    subqueryBuilder.getParameter("endDate")).and(
    subqueryBuilder.get("primaryKey").equal(expBuilder1.get("primaryKey))));
    namedQuery1.setSelectionCriteria(expBuilder1.get("valueDate")
    +.between(expBuilder1.getParameter("startDate"),+
    expBuilder1.getParameter("endDate")).and(
    expBuilder1.get("primaryKey").notExists(subQuery)));
    namedQuery1.addArgument("startDate", java.sql.Date.class);+
    namedQuery1.addArgument("endDate", java.sql.Date.class);+
    // Stack trace
    DEBUG 15:52:54 - ClientSession(27122014)--Exception [TOPLINK-6094] (Oracle TopLink - 11g Release 1 (11.1.1.3.0) (Build 100323)): oracle.toplink.exceptions.QueryException
    Exception Description: The parameter name [startDate] in the query's selection criteria does not match any parameter name defined in the query.
    Query: ReadAllQuery(*myPackage.MyImplementationClass*)Local Exception Stack:
    Exception [TOPLINK-6094] (Oracle TopLink - 11g Release 1 (11.1.1.3.0) (Build 100323)): oracle.toplink.exceptions.QueryException
    Exception Description: The parameter name [startDate] in the query's selection criteria does not match any parameter name defined in the query.
    Query: ReadAllQuery(myPackage.MyImplementationClass)
    at oracle.toplink.exceptions.QueryException.parameterNameMismatch(QueryException.java:996)
    at oracle.toplink.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:227)
    at oracle.toplink.internal.databaseaccess.DatabaseCall.translate(DatabaseCall.java:914)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:192)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:179)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:250)
    at oracle.toplink.internal.queryframework.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:583)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2483)
    at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2441)
    at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:467)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
    at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:445)
    at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2265)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1079)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1063)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1022)
    at oracle.toplink.descriptors.InterfacePolicy.selectAllObjectsUsingMultipleTableSubclassRead(InterfacePolicy.java:171)
    at oracle.toplink.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:462)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:874)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:674)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:835)
    at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:445)
    at oracle.toplink.internal.sessions.AbstractSession.internalExecuteQuery(AbstractSession.java:2265)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1079)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1063)
    at oracle.toplink.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1037)

    Try using the outer query for the parameters,
    change,
    subqueryBuilder.getParameter("startDate"),
    to,
    expBuilder1.getParameter("startDate"),
    If that does not work, try the query without the sub-query to determine if the sub-query is the cause.
    It could be a bug with the sub-query, if you can recreate it on EclipseLink you could log a bug, or contact Oracle support.
    James : http://www.eclipse.org/eclipselink/

  • Querying on interface

    I noticed that Kodo 3.3 supports query on interface - is it part of JDO 2.0
    persistent interface support? What else is implemented? Can we associate
    Interface with Implementation to do the rest of the staff?

    >I noticed that Kodo 3.3 supports query on interface - is it part of JDO 2.0
    persistent interface support? What else is implemented? Can we associate
    Interface with Implementation to do the rest of the staff?We've had querying on interfaces for a long time!
    The Kodo implementation is currently different than JDO 2, in that JDO 2
    requires you to explicitly list your persistent interfaces in metadata, along
    with which classes implement them. Kodo currently just dynamically tracks which
    persistent classes implement which interfaces, and turns any query on an
    interface into a query on the set of the implementing classes.

  • Query on Interface Descriptor

    Hi
    I have a simple question about querying on Interfaces.
    I have an interface called Entity, and 2 implementing classes called Service and ServiceProvider (mapped to tables Services (pk serviceId) and ServiceProviders (pk serviceProviderId)). serviceId and serviceProviderId have independent sequences. In Workbench, both classes are specified as implementing the Entity interface. The Entity interface currently specifies an accessor method getEntityId(), and entityId is a common query key for both classes.
    I want to query against the Entity interface to obtain a single instance, by knowing the entityId and class name.
    How can I formulate a readObject query so that Toplink generates the appropriate SQL:
    select * from services where serviceId = ? or
    select * from serviceProviders where serviceProviderId = ?
    Sorry for the trivial nature of this question - I can't find any examples of querying against interface descriptors in a search of tutorials or the developers guide. The developers guide simply says "If there are multiple implementors of the interfaces, the query returns instances of all implementing classes." and this sounds like it would translate to a UNION ALL SQL query.
    I also have in a separate class a variable one to one mapping where I can specify a class indicator (entityTypeId values). Somehow I feel that I need something like this for the Entity interface descriptor.
    James

    Frankly, this just isn't something that is done that often. In the past decade I can only think of a couple of customers who've asked me about this. I always feel a bit uncomfortable with how querying through interfaces really tends to break polymorphism -- it just doesn't seem very natural from an OO perspective. Now, if instead of an interface you had used a common superclass, that makes more sense. I guess the fact that interfaces don't have state makes this whole area a bit of an OOAD research topic. :)
    That being said, I don't expect TopLink would do an "or" query like you've shown, but would do a UNION.
    My recommendation is to experiement with the queries, perhaps take a look at query-keys (they may be of some help here), and contact support with any feature suggestions you have in this area.
    - Don

  • Interfaces concept in web dynpro

    Hi all
    Can anyone tell me a way of approaching the interfaces concept in web dynpro?
    Thanks n regards
    chaitanya

    Hi,
    Check this links and work on it.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c87806865f26?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#13 [original link is broken]
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/28113de9-0601-0010-71a3-c87806865f26?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#12 [original link is broken]
    http://help.sap.com/saphelp_nw70/helpdata/en/20/a5f7416e61212be10000000a155106/frameset.htm

  • Query on Oracle Concepts: Advantages of ASSM

    Hi,
    A query on Oracle Concepts, specifically on Advantages of ASSM.
    While I am able to understand 'Simplified administration' & 'Increased concurrency', can anyone mention this in simple terms:
    • Dynamic affinity of space to instances in an Oracle Real Application Clusters (Oracle RAC) environment.I guess I know whats Oracle RAC but what it meant by 'Dynamic affinity of space to instances'?
    Regards,
    Ankit Rathi

    Hi Aman,
    I was going through Oracle® Database Concepts 11g Release 2, Chapter 12 Logical Storage Structures (link below):
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/logical.htm#i19599
    *Automatic Segment Space Management*
    The ASSM method uses bitmaps to manage space. Bitmaps provide the following advantages:
    •Simplified administration
    ASSM avoids the need to manually determine correct settings for many storage parameters. Only one crucial SQL parameter controls space allocation: PCTFREE. This parameter specifies the percentage of space to be reserved in a block for future updates (see "Percentage of Free Space in Data Blocks").
    •Increased concurrency
    Multiple transactions can search separate lists of free data blocks, thereby reducing contention and waits. For many standard workloads, application performance with ASSM is better than the performance of a well-tuned application that uses MSSM.
    •Dynamic affinity of space to instances in an Oracle Real Application Clusters (Oracle RAC) environment
    ASSM is more efficient and is the default for permanent, locally managed tablespaces.Regards,
    Ankit Rathi

  • ACE - Query VLAN Interfaces Status

    Hi,
    I am wondering what the status of the query vlan interface means in the command 'show ft peer detail':
    Query Vlan IF State          : UP, Manual validation - please ping peer
    I am pretty sure that I did not see this status when I configured query vlan last time. Current version is A2(2.3).
    Unfortunately this status does not seem to be documented anywhere on CCO.
    I appreciate any help!
    Thanks,
    Daniel

    Hi Daniel,
    The FT Query VLAN interface is an optional, yet very good, feature to be used when using redundant ACE modules or appliances. Without it, if the FT VLAN was to go down, the standby ACE will no longer receive FT heartbeats from the active ACE and therefore take the active role.  However, if the active ACE is still running fine in the active role, then you don't want the standby ACE to take over as active because that will put them into an active/active scenario, which may lead to connectivity issues.
    This is where the FT Query VLAN interface comes in.  If the FT VLAN goes down, the standby ACE will notice this, but before taking the active role, it will ping it's peer IP address configured on the interface that is designated as the FT Query VLAN.  If the ping is successful, then it will stay in the standby role, thereby saving you some headaches.
    The status that you are seeing is the ACE's way of telling you that the interface is UP, but if you want to know if it can successfully ping the peer IP address, then you would have to manually ping the peer IP address from the CLI.  The ACE does not periodically check the ping connectivity through any automatic mechanism.  The automatic mechanism is only triggered by the FT VLAN going down.
    Does this help?
    Sean

  • Query/Read Interface for API

    Is there a query/read interface from the HRMS API's or from the TCA API's?
    We are using customers online to maintain data , but I want to have a custom application to view the data.
    Obvious choice would be through the TCA API's but I cannot find any Query/Read Interfaces there.
    Oracle's Docs seem to say it's possible so could somebody point me in the right direction please
    cheers
    Dominic

    Anyone have any idea of it ?

  • Query all interfaces

    Hi,
    Would really appreciate some assistance in what I 'thought' is a simple task
    This is what I want to do via TCL / EEM :
    1.)  Enumerate all interfaces on the switch or just query the running config
    2.)  Query each interface config
    3.)  If the interface config doesn't contain the sting 'authentication port-control auto' - send an email with the resulting interface name etc
    I'm starting to lose my mind trying to do this 
    Thanks and regards,
    Bill

    Try this:
    event manager applet intf-auth
    event none
    action 001  cli command "enable"
    action 002  cli command "show ip int brie"
    action 003  set output "$_cli_result"
    action 004  set intfs ""
    action 005  foreach line "$output" "\n"
    action 006   string trim $line
    action 007   set line $_string_result
    action 008   string length $line
    action 009   if $_string_result eq 0
    action 010    continue
    action 011   end
    action 012   regexp "^Interface" "$line"
    action 013   if $_regexp_result eq "1"
    action 014    continue
    action 015   end
    action 016   regexp "#" "$line"
    action 017   if $_regexp_result eq "1"
    action 018    continue
    action 019   end
    action 020   regexp "^([^[:space:]]+)" "$line" match intf
    action 021   cli command "show run interface $intf"
    action 022   regexp "authentication port-control auto" "$_cli_result"
    action 023   if $_regexp_result eq "0"
    action 024    append intfs " $intf"
    action 025   end
    action 026  end
    action 027  string length "$intfs"
    action 028  if $_string_result gt "0"
    action 029   mail from "[email protected]" to "[email protected]" server "10.1.1.1" subject "Interfaces missing auth port-control" body "The following interfaces are missing 'auth port-control auto': $intfs"
    action 030  end

  • Syntax error in OBIEE generated Physical query - Advance filter concept

    I encountered a syntax error when running a report with the help of advanced filter concept.
    I am getting syntax error at the physical query generated by the OBIEE for main report.
    I used a sub report with the help of advanced filter concept in main report.
    I am posting the physical query for the convenience.
    select D1.c2 as c1,
    D1.c1 as c2
    from
    (select sum(T600347.sales_usd) as c1,
    T601002.currency as c2
    from
    (Select distinct currency from pfact) T601002,
    pfact T600347
    where ( T600347.currency = T601002.currency and T600347.pdate between ( select distinct min(D1.c1) as c1* from
    (select D1.c1 as c1
    from
    (select D1.c1 as c1
    from
    *(select max(T600425.pdate) as c1*
    from
    *(select distinct pdate from pdates where pdate is not null) T600425*
    where  ( T600425.pdate < 11/22/2010 )
    *) D1*
    ) D1
    ) D1 ) and '11/25/2010')
    group by T601002.currency
    ) D1
    I executed the query against my database(sybase) in query tool. It showed error.
    I took out the column alias generated by the OBIEE ("as c1" as underlined). Then the query is working fine.
    How to disable OBIEE from generating the alias.
    Is there any way to do it.
    If obiee is generating the physical query, i am suprised to see a syntax error.
    The bold part is the query from Intermediate report
    I underlined the problematic part.
    Please help me. This is an urgent reuirement,
    Thanks in advance for the help.

    HI,
    When I execute the query on query tool ( my database is sybase)
    I am geting error at "as c1" part, as underlined in the query.
    when I remove that and execute the query, It is generating the output.
    here is the better view of query and error:
    http://img255.imageshack.us/img255/4719/25187227.jpg

  • Query abt interface

    hi all,
    my query is on outbound interface, i have already an idoc which has data i have to retrieve it from z_tp_idocread function module.and i have to map the fields with idoc fields those idoc fields i can find from zrmd_a07 for custom fields and hrmd_a07 for normal fields.so i have to map in the format of header trailer and body and i have to send it ti flat file
    through outbound interface.
    i want an example program for this.its very urgent.
                   try to help me in this asap.
                               thanking you,

    and how do we .. create a connection pooling

  • LMS 4.2.3 Query on Interface utilization report

    Hi All,
    Interface Utilization report displays the interface utilization data for each device polled for the Interface Utilization
    template. The information is presented using the percentage specifier.
    For eg its displayed % (Rx Max%,Rx Avg%,RxMin%,
    Tx Max%,Tx Avg%,TxMin%)
    I wants report should have the data(interface utilization In Bytes of data)
    Can we display the data instead of the percentage?? is it possible ???
    Regards,
    Channa

    Hi Channa,
    log into dbreader using the following::
    http://servername : 1741/dbreader/dbreader.html
    or
    https:// servername : 443/dbreader/dbreader.html
    user Id is DBA
    Database Name is upm
    password :: user defined (by default password is c2ky2k)
    1.       Here is the query to get the pollerwise managed MIBObjects:
    "select count (*), PollerName from Poller_Details_Table a,Poller_Definition_Table b where a.PollerId = b.PollerId and b.Poller_State NOT IN (1) Group by b.PollerName;"
    2.       Here is the query to get the total mibobject count for the active pollers
    “select count (*) from Poller_Details_Table a,Poller_Definition_Table b where a.PollerId =
    b.PollerId and b.Poller_State NOT IN (1);”
    Hope it will help
    Thanks-
    Afroz
    ***Ratings Encourages Contributors ***

  • Named Query in Interface

    HI,
    I’ve a named query in a class descriptor set in workbench and if I call the method
    Object executeQuery(java.lang.String queryName, java.lang.Class domainClass, java.util.Vector argumentValues)
    Works fine. My domain class implements an interface and I don’t want to expose the domain class to my caller. For this to work is there a way to associate the named query to the interface so that the interface can be passed in the above method instead of concrete class?
    If not how can I set the query in Toplink so that I can use the following method
    executeQuery(java.lang.String queryName, java.lang.Object arg1)
    In the current setup when I try to use the above method I’m getting following exception
    Exception [TOPLINK-6026] (OracleAS TopLink - 10g (9.0.4.3) (Build 040412)): oracle.toplink.exceptions.QueryException
    Exception Description: Query named [retrieveBases] is not defined. Domain class: []
         at oracle.toplink.exceptions.QueryException.queryNotDefined(QueryException.java:587)
         at oracle.toplink.exceptions.QueryException.queryNotDefined(QueryException.java:580)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1020)
    Thanks
    -Mani

    If you associate the interface with the class' descriptor you should be able to execute queries against the interface and have it execute against the correct class.
    In the MW, in your descriptor use the advanced property "Interface Alias" and set the class' interface.
    Through the code API, you would use the interface policy,
    descriptor.getInterfacePolicy().addParentInterface(MyInterface.class);

  • Brief conclusion of Boss class and there interface concept or basic programming architecture ?

    I am new in this indesign development so i am studying the  documentation provide by sdk till date i think lots of concept are clear to me but still while doing practicle implementation many concept intermixed in my mind .one of them is "command" .so please tell me in brief about it with practical example of creating new document having text frame in indesigen using it .also there are  lots of question in my mind  regarding interface and boss class anyone please share there knowledge regarding them in brief

    Due to a copy/paste glitch, some necessary spaces have inadvertently been removed.  If I could fix this, I would.

  • Query Network interface with C#

    Hello,
    I'm developing a C# winforms application under Windows server 2008 (64bit)
    Is there a way to query all network interfaces installed in the PC and check their IP address and if there is an ethernet connection (connected \ not connected) ?
    I want to do it with Microsoft C# classes. 
    Best regards,
    Z.V

    Hi,
    Solution 1:>
    Step1:>
    UdpClient u = new UdpClient(remoteAddress, 1);
    IPAddress localAddr = ((IPEndPoint)u.Client.LocalEndPoint).Address;
    Step2:>
    foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
    IPInterfaceProperties ipProps = nic.GetIPProperties();
    // check if localAddr is in ipProps.UnicastAddresses
    Solution 2:>
    foreach(NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
    if(ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
    Console.WriteLine(ni.Name);
    foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
    if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
    Console.WriteLine(ip.Address.ToString());
    Documentation:>
    NetworkInterface.GetAllNetworkInterfaces Method
    Good Tutorial:>
    http://www.codeproject.com/Articles/64975/Detect-Internet-Network-Availability
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

Maybe you are looking for

  • Error while activating a datasource

    Hi All, We have created a generic datasource. While we are activating the datasource, its throwing up a message saying: "Error in database while accessing a table." And also "Generation of conversion exit and PSA update". Please advice. Thanks & Rega

  • How to change the direction of a moving object

    I am trying to make a connect four program for class, and i am trying to make it so the red check piece move down. But instead it move left n right -.-, ive tried changing the coordinates but then the piece would just spin in circle or spins out of c

  • Transcoding from AVCHD 60i for 24p

    Sorry for this long post. I have spent a long time looking for answers. I would like to combine different formats into one sequence. I primarily have AVCHD 1080p24 but need to include some 1080i60. All shot with Panasonic Lumix GH2. I have logged and

  • Can't restore iPad, not enough space, lost Pin to get in.

    Password was changed on iPad and when trying to restore to factory settings, I can't as there is not enough space. What can I do?  I can't see the iPad on "Find my iPad" on iCloud either, so that is not an option.

  • Footers, tables, secondary navbars or frames, different sites etc.

    Hey all, I moved completely away from Windows years ago to Macs and Linux except for web page building. I continued to use Frontpage because I understood it and it worked for my level of need and capability. Today I began attacking an overdue site fo