Skip to Main Content

Java APIs

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!

Generics and supertypes

843793Apr 9 2010 — edited Apr 30 2010
Hi,

I have an issue with Generics and types, I hope I may find some help here.

I have the following map :
protected static HashMap<String, Action<EndpointClient>> dictionary = 
    new HashMap<String, Action<EndpointClient>>();
In this map I want to put :
protected static final Action<EndpointClient> ACTION_SEND_PRIVATE = new ActionSendPrivateMessage();
protected static final Action<EndpointClientAdmin> ACTION_SEND_TO_ALL = new ActionSendMessageToAll();

dictionary.put(Constants.MSG_SEND_PRIVATE, ACTION_SEND_PRIVATE);
dictionary.put(Constants.MSG_SEND_TO_ALL, ACTION_SEND_TO_ALL);
I have a problem in adding the ACTION_SEND_TO_ALL variable in the map, it says :
The method put(String, Action<EndpointClient>) in the type+
HashMap<String,Action<EndpointClient>> is not applicable for the arguments (String, Action<EndpointClientAdmin>)+

However EndpointClientAdmin extends EndpointClient ...

In java it's possible to to do something like:
List myList = new ArrayList();
and thus reduce the visibility of the class ArrayList.

Why isn't it possible with Generics like this case above ?

Thank you very much ...

Comments

tlokweng
Answer

クエリトランスフォーメーションのビューマージで2階層のクエリが1階層に置換され、結果として各行でプロシジャが2回づつ呼ばれているということですね。なので単純にプロシジャを呼んでいるインラインビューがマージされないようにすれば解決します。素直にNO_MERGEヒントでOKでしょう。テーブルサイズが大きくなければWITHにしてファクタリングするのもアリですね。

> create table test_table(n) as select 1 from dual union select 2 from dual;

> create function test_func return varchar2 as begin RETURN DBMS_RANDOM.STRING('x', 10); end;

> select n, r r1, r r2 from (select n, test_func r from test_table);

        N R1          R2

--------- ------------ ------------

        1 AJ1LNZ30HD  LAMQV4CQUY

        2 F911DGQDYZ  ID8FDREGKF

> select n, r r1, r r2 from (select /*+ no_merge */ n, test_func r from test_table);

--------- ------------ ------------

        1 K5MPMUR3DQ  K5MPMUR3DQ

        2 DD2Y5NUWPM  DD2Y5NUWPM

> with t as (select /*+ materialize */ n, test_func r from test_table) select n, r r1, r r2 from t;

--------- ------------ ------------

        1 0F2RE7Y8C3  0F2RE7Y8C3

        2 O6C4WCBAFP  O6C4WCBAFP

Marked as Answer by 988825 · Sep 27 2020
988825

tlokweng様、お礼が遅くなってしまい、申し訳ありません。サンプルまでお示しくださいまして、誠にありがとうございます。

クエリトランスフォーメーションがこのようなSQLに対し作用しているとは全く一度も想像すらつきませんでした。

頂戴したサンプルで動作も確認出来ましたので、本来の組み込み先に入れてみようと思います。

ありがとうございました。

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 28 2010
Added on Apr 9 2010
4 comments
257 views