Should Collections be used as return types across threads?

I am wondering when, if ever, it is appropriate to use a Collection as the return type of a method in a multi-threaded environment. Here is our situation:
We have four classes -- Widget, WidgetManager, ClientA, and ClientB. ClientA and ClientB are running in different Threads from each other and from the WidgetManager.
The WidgetManager class that uses a Collection of Widgets internally, and passes the Collection (or an Iterator over it) out as a return value of a method to ClientA, which is running in another thread. ClientA would start to go through it using next() and hasNext() of the Iterator. If the WidgetManager were to get a request from ClientB running in another thread to eliminate a Widget, it would attempt to remove it from the Collection. If ClientA were still looping through the Iterator, this would throw an IllegalStateException b/c the system would be in an inconsistent state. The Iterator given to the ClientA is directly linked to the actual Collection in the WidgetManager (am I right so far?).
In my opinion, in most cases we don't want to synchronize Collections. In the example above, if we had passed out a synchronized Collection, then the WidgetManager couldn't touch the collection while the client was looping through the Iterator. If the client got hung up while looping, then the WidgetManager would be hung up. In this case, I think that it will be better to use the toArray() method of Collection to just dump out the contents to a plain array of Objects. Actually, the WidgetManager could convert this array of Objects to an array of Widgets before passing it out, which would give us the type checking that we don't get with Containers.
The condition where you would want to use a synchronized Collection would be when you actually want the client to do some writing or removing from the Collection. I would expect this to be pretty rare since you usually dont want to give clients access to an interal member (the Collection) of a class.
I think that it is also possible to have read-only Collections, but I think (don't know for sure) that you would still have the same IllegalStateException or synchronization probelms.
Can someone point out the errors in my thinking? Or should you generally only use Collections as internal members in a multi-threaded environment, and use toArray() whenever you want to pass the Collection's data outside of the class?
Thanks for any help.
Keith

I haven't tested what happens when you synchronize the
Collection, but I think that you are right. But this
causes the problem that I mentioned in the first post.
That is, what happens if your client STARTS running
through the Iterator, and then stops or gets hung up
for some reason? I assume that you're still blocked.
And it's pretty important to me in this case to not
t be blocked -- WidgetManager is the highest level
class in the system.
I'd like to know if anyone has tested this.
The Iterator implementations used in java.util do not use any synchronization by itself, (which is what you would expect since synchronization over multiple method call will involve much more complications and slower performance) . With iterator, you have to provide the necessary synchronization yourself to maintain thread-safety like this
Iterator itr = get Iterator from collectionInstance ;
synchronized(collectionInstance) {
while(itr.hasNext())
process itr.next() ...
As long as your client code gracefully exits the synchronized block on a stop( or hangup, given that it is detected and handled fast enough), it will not be a problem.
Also, I'd like an example of when you WOULD want to
return a Collection. I'm specifically interested in
when you would want to return one in a multi-threaded
environment, but I'm beginning to wonder when you
would EVER want to return one from a method.
Collections are great for internal uses, but you lose
type-checking and you expose the internals of your
class to modification when you use them as return
types. And if you're returning a read-only
Collection, you might as well return an array, right?Using a read-only proxy will be much faster and space-efficient than toArray().

Similar Messages

  • Should/does -MyInterface give MyInterface return types?

    The variance-overview.pdf says that List<-E> has Object as the return type of the get method. If this is true, I'm disappointed. I'd expect the following to work quite happily: List<-List<*>> myList = buildList();
    List<*> elt1 = myList.get(0);There's no obvious reason why Object should be a supertype of List.

    I'm still a bit fuzzy about contravariance, but it all depends on what your buildList() method returns. I think this is all legal code:
        List<Object> list1 = new ArrayList<Object>();
        List<List<*>> list2 = new ArrayList<List<*>>();
        list1.add (new Object());
        list2.add (new ArrayList<Integer>());
        List<-List<*>> list3;
        list3 = list2;
        list3 = list1;
        Object o = list3.get(0); // o is not a List!Either of list1, list2 or list3 will accept list.add(new ArrayList<Integer>()) - however at the price that nothing can be guaranteed about the type of the contents of the array (in the second case, the list is only guaranteed to contain Object).
    What you want is for your buildList() method to return List<+List<*>>, the variant case (since you are reading from it).
        List<ArrayList<*>> list1 = new ArrayList<ArrayList<*>>();
        List<List<*>> list2 = new ArrayList<List<*>>();
        list1.add (new ArrayList<Integer>());
        list2.add (new ArrayList<Integer>());
        List<+List<*>> list3;
        list3 = list2;
        list3 = list1;
        List<*> o = list3.get(0); // o is a List

  • Error: attempting to use incompatible return type

    Hi, I am getting the following error while building my application. I want to support jdk 1.5 to the product.
    How can I resolve this issue... I dont have the new lib for the same!
    [javac] C:\venus\src\com\martquest\rulebase\RulebaseDom.java:61: getDomConfig() in org.apache.xerces.dom.CoreDocumen
    tImpl cannot implement getDomConfig() in org.w3c.dom.Document; attempting to use incompatible return type

    I have something like
    package org.apache.xerces.dom3;
    public interface DOMConfiguration {
    and I want to change org.apache.xerces.dom3.DOMConfiguration to org.w3c.dom.DOMConfiguration But I cant change this as it is present in jar file. This supports jdk 1.4 and I want to give a support of jdk 1.5

  • Should Java be used for this type of application

    I am building a knowledgebase that is going to be searchable in web browser. Lucene is good search engine and it's in Java so would use JSP pages. However everyone has Win 2000 machines and it's going to be annoyin to install that on everyone's machine. Is there a way to put it on a shared drive and make it work ? I'm confused.

    Java should be used for everything... :)
    You could write an application for a central server, and then make a web interface for it that your users could use. You could write a process that would index your data into a database table, which would be easier to search, and then have your web frontend search the database based on whatever requirements the user specifies.
    I'm not really familiar with lucene, but I'm sure you could run it on a server, and make a web interface with java to interact with it.

  • How should I handle using this socket on multiple threads?

    Hey there, I'm writing a SocketServer app to handle client communications and I've run into something I'm not sure how to handle. Currently, I have the main method create the SocketServer and start new threads whenever a client connects and keeps a list of clients that need to be updated with some info ("Stuff") (Basically a list, which when changed, each update will be sent to all clients on the list to be informed of updates). Each thread that's created when a new client connects is passed the instance of the 'PoolHandler' class, which is supposed to handle updates to the "Stuff" and send updates to any clients that need them. Currently, when a client adds itself to the list of users that need to be informed of updates on "Stuff", the thread that handles that client adds the client name and socket to a hashmap in 'PoolHandler' and anytime the "Stuff" is updated, 'PoolHandler' accesses the passed socket and sends the updates. I realize I'm probably not doing a very good job of explaining this, so I'll show my code:
    public static void main(String[] args) throws IOException {
            final PoolHandler pool = new PoolHandler();
            ServerSocket serverSocket = null;
            while (listening) {
                new SNMultiServerThread(clients, pool, serverSocket.accept()).run();
    public class SNMultiServerThread implements Runnable {
        public void run() {
            try {
                out = new BufferedOutputStream(socket.getOutputStream());
                in = new BufferedInputStream(socket.getInputStream());
                try {
                    while ((read = in.read(input)) > 0) {
                        outputList = snp.process(input);
                        if (outputList != null && !outputList.isEmpty()) {
                            for (byte[] output : outputList) {
                                System.out.println("Transmitting: " +
                                        new String(output, 0, output.length));
                                synchronized(socket) {
                                    out.write(output);
                                    out.flush();
                } catch (SocketException e) {
    public class PoolHandler {
        public PoolHandler() {
        private void updateClients(String update, String game, String team) throws IOException {
            if (update.equalsIgnoreCase("add")) {
                if (game.equalsIgnoreCase(CS)) {
                    clientUpdateListDummy = clientUpdateListCs;
                } else {
                // The HashMap here is K=String, V=Socket
                for (Map.Entry<String, Socket> m : clientUpdateListDummy.entrySet()) {
                    try {
                        out = new BufferedOutputStream(m.getValue().getOutputStream());
                        out.write(snp.prepareOutput(ADD_TEAM_REPLY, team));
                        out.flush();
                    } catch (SocketException e) {
            } else if (update.equalsIgnoreCase("remove")) {
                if (game.equalsIgnoreCase(CS)) {
                    clientUpdateListDummy = clientUpdateListCs;
                } else {
                // The HashMap here is K=String, V=Socket
                for (Map.Entry<String, Socket> m : clientUpdateListDummy.entrySet()) {
                    try {
                        out = new BufferedOutputStream(m.getValue().getOutputStream());
                        synchronized(m.getValue()) { // synchronizing on the socket connected to the client, m.getValue()
                            out.write(snp.prepareOutput(REMOVE_TEAM_REPLY, team));
                            out.flush();
                    } catch (SocketException e) {
    }I attempted adding a synchronized block in the second for loop in PoolHandler, although i'm not sure if I need one at all or if that'll do the trick. The question, I guess, is should I be accessing the socket and then the outputstream for it from here (perhaps with the synchronized block that I added in the second for loop)? Or should I perhaps add a method in the Runnable class that transmits data via the socket and call that from PoolHandler? If I go with the second approach, can I simply pass the thread's name instead of the socket and use, say, m.getValue().transmitThisDataOverTheSocket(myData)? Thanks again, I hope this is clear. :)

    So I've got another question about my code: will the PoolHandler class be responsive if used in the main() thread or do I need to implement Runnable in it and create a new thread also? If so, how should I go about it since I don't want PoolHandler to do anything other than keep track of clients and a few other client-related variables? Here's my main():
    public static void main(String[] args) throws IOException {
            final PoolHandler pool = new PoolHandler();
            ServerSocket serverSocket = null;
            boolean listening = true;
            final int port = 4555;
            try {
                serverSocket = new ServerSocket(port);
            } catch (IOException e) {
                System.err.println("Couldn't listen on port: " + port);
                System.exit(-1);
            while (listening) {
                new SNThreadReader(pool, serverSocket.accept()).run();
            serverSocket.close();
        }

  • Is there a way to end a method that has no return type?

    Without using an exception, as they are costly I am told, and without using may if then statements, is it possible to end a method if some criteria isn't met.
    example.
    public void doThis(){
      // the method relies on the state of some
      // other things.
      if(!someBoolean) endHere
      // then following is the rest of the method.
      // I'd like to be able to do this so that the "meat"
      // of the method is located under the conditions
      // that must be met.
    }... Any thoughts?
    Thank You

    No need to hide or commit ritual suicide, the "void" keyword could lead you to think that your method can't use the return statement. At least you wrote code to investigate and didn't spend 10 or 20 posts asking for verification. Be aware, some folk will tell you that there should be only one exit point from the method, often this is true. In large methods you can get lost in the execution path if there are multiple exit points. I think it's a judgement call.
    As for returning a bogus boolean, but, from a design point of view, if your method really doesn't have anything to return to its caller then the signature should reflect that with a return type of void (I know you are suggesting returning the bogus boolean for a different reason, and you've abandoned the idea anyway, I'm just being pedantic here)(indulge me). Returning a bogus boolean makes the class method more difficult to understand from a design and JavaDoc point of view because I, as the user of your method, will see it returing a boolean and expect to be able to use that value, and it might color my view of what the method does.
    Lee

  • "Primitive Type Returned", when I try to configure the data return type.

    I am basically following this tutorial, Getting started with ColdFusion and Flash Builder 4 beta, but instead of using the database provided, I am using SQL Server 2008.  I am now stuck on the part titled, "Configuring the data return type".  In step 5 of this section, I submit my credentials and then I get a popup titled:
    Primitive Type Returned
    The operation returned a response of the type "Object".
    You may either update server code to fix the returned data or Click OK to set "Object" as the return type of this operation.
    I am not sure if "server code" would be my database and/or the Coldfusion code that was provided in this tutorial.  I am thinking that its the former, however I am new to both technologies.  Would anyone know why FlashBuilder will not strong type this data for me?

    Hi,
    Thanks for your feedback!
    The server code here means the ColdFusion code provided in the tutorial.
    The "Configure return type" step is performed to change the return type of the function.
    If you notice after importing the CFC in the Flash Builder the return type of getAllData was Object but with this step you are trying to change it to a Strong Type.
    So context click on the getAllData function,select 'Configure return type', enter "EmployeeSalesData" click NEXT , enter valid RDS credentials in the security dialog and click FINISH.
    This should have ideally set your return type to "EmployeeSalesData"(Strong type).
    Also if you are extremely new to this i suggest you to pick up a pre-release build of Flash Builder which has a COOL feature which can help you get started pretty fast and simplify most of these workflows.
    To avail for the pre-release build please send a mail to [email protected]
    Hope this helps!
    Thanks,
    Balaji
    http://balajisridhar.wordpress.com

  • Managing statistics for object collections used as table types in SQL

    Hi All,
    Is there a way to manage statistics for collections used as table types in SQL.
    Below is my test case
    Oracle Version :
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> Original Query :
    SELECT
         9999,
         tbl_typ.FILE_ID,
         tf.FILE_NM ,
         tf.MIME_TYPE ,
         dbms_lob.getlength(tfd.FILE_DATA)
    FROM
         TG_FILE tf,
         TG_FILE_DATA tfd,
              SELECT
              FROM
                   TABLE
                        SELECT
                             CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                             OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
                        FROM
                             dual
         )     tbl_typ
    WHERE
         tf.FILE_ID     = tfd.FILE_ID
    AND tf.FILE_ID  = tbl_typ.FILE_ID
    AND tfd.FILE_ID = tbl_typ.FILE_ID;
    Elapsed: 00:00:02.90
    Execution Plan
    Plan hash value: 3970072279
    | Id  | Operation                                | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                         |              |     1 |   194 |  4567   (2)| 00:00:55 |
    |*  1 |  HASH JOIN                               |              |     1 |   194 |  4567   (2)| 00:00:55 |
    |*  2 |   HASH JOIN                              |              |  8168 |   287K|   695   (3)| 00:00:09 |
    |   3 |    VIEW                                  |              |  8168 |   103K|    29   (0)| 00:00:01 |
    |   4 |     COLLECTION ITERATOR CONSTRUCTOR FETCH|              |  8168 | 16336 |    29   (0)| 00:00:01 |
    |   5 |      FAST DUAL                           |              |     1 |       |     2   (0)| 00:00:01 |
    |   6 |    TABLE ACCESS FULL                     | TG_FILE      |   565K|    12M|   659   (2)| 00:00:08 |
    |   7 |   TABLE ACCESS FULL                      | TG_FILE_DATA |   852K|   128M|  3863   (1)| 00:00:47 |
    Predicate Information (identified by operation id):
       1 - access("TF"."FILE_ID"="TFD"."FILE_ID" AND "TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
       2 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
    Statistics
              7  recursive calls
              0  db block gets
          16783  consistent gets
          16779  physical reads
              0  redo size
            916  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed Indexes are present in both the tables ( TG_FILE, TG_FILE_DATA ) on column FILE_ID.
    select
         index_name,blevel,leaf_blocks,DISTINCT_KEYS,clustering_factor,num_rows,sample_size
    from
         all_indexes
    where table_name in ('TG_FILE','TG_FILE_DATA');
    INDEX_NAME                     BLEVEL LEAF_BLOCKS DISTINCT_KEYS CLUSTERING_FACTOR     NUM_ROWS SAMPLE_SIZE
    TG_FILE_PK                          2        2160        552842             21401       552842      285428
    TG_FILE_DATA_PK                     2        3544        852297             61437       852297      852297 Ideally the view should have used NESTED LOOP, to use the indexes since the no. of rows coming from object collection is only 2.
    But it is taking default as 8168, leading to HASH join between the tables..leading to FULL TABLE access.
    So my question is, is there any way by which I can change the statistics while using collections in SQL ?
    I can use hints to use indexes but planning to avoid it as of now. Currently the time shown in explain plan is not accurate
    Modified query with hints :
    SELECT    
        /*+ index(tf TG_FILE_PK ) index(tfd TG_FILE_DATA_PK) */
        9999,
        tbl_typ.FILE_ID,
        tf.FILE_NM ,
        tf.MIME_TYPE ,
        dbms_lob.getlength(tfd.FILE_DATA)
    FROM
        TG_FILE tf,
        TG_FILE_DATA tfd,
            SELECT
            FROM
                TABLE
                        SELECT
                             CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                             OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
                        FROM
                             dual
        tbl_typ
    WHERE
        tf.FILE_ID     = tfd.FILE_ID
    AND tf.FILE_ID  = tbl_typ.FILE_ID
    AND tfd.FILE_ID = tbl_typ.FILE_ID;
    Elapsed: 00:00:00.01
    Execution Plan
    Plan hash value: 1670128954
    | Id  | Operation                                 | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                          |                 |     1 |   194 | 29978   (1)| 00:06:00 |
    |   1 |  NESTED LOOPS                             |                 |       |       |            |          |
    |   2 |   NESTED LOOPS                            |                 |     1 |   194 | 29978   (1)| 00:06:00 |
    |   3 |    NESTED LOOPS                           |                 |  8168 |  1363K| 16379   (1)| 00:03:17 |
    |   4 |     VIEW                                  |                 |  8168 |   103K|    29   (0)| 00:00:01 |
    |   5 |      COLLECTION ITERATOR CONSTRUCTOR FETCH|                 |  8168 | 16336 |    29   (0)| 00:00:01 |
    |   6 |       FAST DUAL                           |                 |     1 |       |     2   (0)| 00:00:01 |
    |   7 |     TABLE ACCESS BY INDEX ROWID           | TG_FILE_DATA    |     1 |   158 |     2   (0)| 00:00:01 |
    |*  8 |      INDEX UNIQUE SCAN                    | TG_FILE_DATA_PK |     1 |       |     1   (0)| 00:00:01 |
    |*  9 |    INDEX UNIQUE SCAN                      | TG_FILE_PK      |     1 |       |     1   (0)| 00:00:01 |
    |  10 |   TABLE ACCESS BY INDEX ROWID             | TG_FILE         |     1 |    23 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       8 - access("TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
       9 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
           filter("TF"."FILE_ID"="TFD"."FILE_ID")
    Statistics
              0  recursive calls
              0  db block gets
             16  consistent gets
              8  physical reads
              0  redo size
            916  bytes sent via SQL*Net to client
            524  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              2  rows processed
    Thanks,
    B

    Thanks Tubby,
    While searching I had found out that we can use CARDINALITY hint to set statistics for TABLE funtion.
    But I preferred not to say, as it is currently undocumented hint. I now think I should have mentioned it while posting for the first time
    http://www.oracle-developer.net/display.php?id=427
    If we go across the document, it has mentioned in total 3 hints to set statistics :
    1) CARDINALITY (Undocumented)
    2) OPT_ESTIMATE ( Undocumented )
    3) DYNAMIC_SAMPLING ( Documented )
    4) Extensible Optimiser
    Tried it out with different hints and it is working as expected.
    i.e. cardinality and opt_estimate are taking the default set value
    But using dynamic_sampling hint provides the most correct estimate of the rows ( which is 2 in this particular case )
    With CARDINALITY hint
    SELECT
        /*+ cardinality( e, 5) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1467416936
    | Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |      |     5 |    10 |    29   (0)| 00:00:01 |
    |   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     5 |    10 |    29   (0)| 00:00:01 |
    |   2 |   FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    With OPT_ESTIMATE hint
    SELECT
         /*+ opt_estimate(table, e, scale_rows=0.0006) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Execution Plan
    Plan hash value: 4043204977
    | Id  | Operation                              | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                       |      |     5 |   485 |    29   (0)| 00:00:01 |
    |   1 |  VIEW                                  |      |     5 |   485 |    29   (0)| 00:00:01 |
    |   2 |   COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     5 |    10 |    29   (0)| 00:00:01 |
    |   3 |    FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    With DYNAMIC_SAMPLING hint
    SELECT
        /*+ dynamic_sampling( e, 5) */*
    FROM
         TABLE
              SELECT
                   CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
                   OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
              FROM
                   dual
         ) e ;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1467416936
    | Id  | Operation                             | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |      |     2 |     4 |    11   (0)| 00:00:01 |
    |   1 |  COLLECTION ITERATOR CONSTRUCTOR FETCH|      |     2 |     4 |    11   (0)| 00:00:01 |
    |   2 |   FAST DUAL                           |      |     1 |       |     2   (0)| 00:00:01 |
    Note
       - dynamic sampling used for this statement (level=2)I will be testing the last option "Extensible Optimizer" and put my findings here .
    I hope oracle in future releases, improve the statistics gathering for collections which can be used in DML and not just use the default block size.
    By the way, are you aware why it uses the default block size ? Is it because it is the smallest granular unit which oracle provides ?
    Regards,
    B

  • Hi i have an ipad mini and i have not used it for 2 month or more. Today i have tried to use it i came across with a problem. my Ipad is blocked and it asks me to wait 23,401,418 :) what should i do need your help. thanks

    hi i have an ipad mini and i have not used it for 2 month or more. Today i have tried to use it i came across with a problem. my Ipad is blocked and it asks me to wait 23,401,418 what should i do need your help. thanks 

    Have you charged ipad Try a Reboot press & hold power button & menu button hold both down until you see Apple Logo You may need to do this more than once. Bsydd uk

  • Exception: "The type "Collection" as used in the variable/parameter declarations

    I am getting the following exception when I try to run the test code.
    What could be causing it ?
    I am running Kodo 2.4.3 with JDK 1.4.1
    EXCEPTION
    javax.jdo.JDOFatalInternalException: [agencyNames:[AGENCY1, AGENCY2]]
    NestedThrowables:
    javax.jdo.JDOUserException: The type "Collection" as used in the
    variable/parameter declarations could not be found in the imports.
    TEST CODE
    JDOFactory jdoFactory = new JDOFactory();
    PersistenceManager pm = jdoFactory.getPersistenceManager("");
    try
    Class agencyClass = Agency.class;
    Extent agencyExtent = pm.getExtent(agencyClass, false);
    String filter = "agencyNames.contains(agencyName)";
    List agencyNames = Arrays.asList(new String[]{"AGENCY1",
    "AGENCY2"});
    String param = "Collection agencyNames";
    Query q = pm.newQuery(agencyExtent, filter);
    q.declareParameters(param);
    Collection deps = (Collection) q.execute(agencyNames);
    System.out.println("SIZE :" + deps.size());
    catch (Exception ex)
    ex.printStackTrace();
    JDO Mapping and Class
    package test;
    import java.util.*;
    public class Agency
    private String agencyName;
    private String hostCarrierCode;
    //Getter and Setter
    public static class Id
    public String agencyName;
    public String hostCarrierCode;
    //Application ID definition
    ?xml version="1.0"?>
    <jdo>
    <package name="test">
    <class name="Agency" identity-type="application"
    objectid-class="Agency$Id">
    <extension vendor-name="kodo" key="table" value="AGENCIES"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="agencyName" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="AGENCY_NAME"/>
    </field>
    <field name="hostCarrierCode" primary-key="true" >
    <extension vendor-name="kodo" key="data-column"
    value="CARRIER_CODE"/>
    </field>
    </class>
    </package>
    </jdo>

    Kodo 2.4.3 does not support using collections as parameters.
    Kodo 2.5.0, due to be released shortly, does support this. See
    http://solarmetric.com/Software/beta/2.5.0 to get the latest release
    candidate.
    -Patrick
    On Thu, 05 Jun 2003 22:26:36 +0000, B K Adarsh wrote:
    I am getting the following exception when I try to run the test code.
    What could be causing it ?
    I am running Kodo 2.4.3 with JDK 1.4.1
    EXCEPTION
    javax.jdo.JDOFatalInternalException: [agencyNames:[AGENCY1, AGENCY2]]
    NestedThrowables:
    javax.jdo.JDOUserException: The type "Collection" as used in the
    variable/parameter declarations could not be found in the imports.
    TEST CODE
    JDOFactory jdoFactory = new JDOFactory();
    PersistenceManager pm = jdoFactory.getPersistenceManager("");
    try
    Class agencyClass = Agency.class;
    Extent agencyExtent = pm.getExtent(agencyClass, false);
    String filter = "agencyNames.contains(agencyName)";
    List agencyNames = Arrays.asList(new String[]{"AGENCY1",
    "AGENCY2"});
    String param = "Collection agencyNames";
    Query q = pm.newQuery(agencyExtent, filter);
    q.declareParameters(param);
    Collection deps = (Collection) q.execute(agencyNames);
    System.out.println("SIZE :" + deps.size());
    catch (Exception ex)
    ex.printStackTrace();
    JDO Mapping and Class
    package test;
    import java.util.*;
    public class Agency
    private String agencyName;
    private String hostCarrierCode;
    //Getter and Setter
    public static class Id
    public String agencyName;
    public String hostCarrierCode;
    //Application ID definition
    ?xml version="1.0"?>
    <jdo>
    <package name="test">
    <class name="Agency" identity-type="application"
    objectid-class="Agency$Id">
    <extension vendor-name="kodo" key="table" value="AGENCIES"/>
    <extension vendor-name="kodo" key="lock-column" value="none"/>
    <extension vendor-name="kodo" key="class-column" value="none"/>
    <field name="agencyName" primary-key="true">
    <extension vendor-name="kodo" key="data-column"
    value="AGENCY_NAME"/>
    </field>
    <field name="hostCarrierCode" primary-key="true" >
    <extension vendor-name="kodo" key="data-column"
    value="CARRIER_CODE"/>
    </field>
    </class>
    </package>
    </jdo>--
    Patrick Linskey
    SolarMetric Inc.

  • How to get the Benefits Rate multiplier value in HCM extract ? used Extract rule type Fastfomula, but returns null.

    how to get the Benefits Rate multiplier value in HCM extract ? used Extract rule type Fastfomula, but returns null.
    Formula:
    DEFAULT FOR BEN_ABR_NAME IS 'NA'
    DEFAULT FOR l_rate_multiplier IS 'X'
    L_BG_ID = GET_CONTEXT(BUSINESS_GROUP_ID, 1)
    L_EFF_DATE = GET_CONTEXT(EFFECTIVE_DATE, to_date('1951/01/01 00:00:00'))
    L_ABRT_ID = GET_CONTEXT(ACTY_BASE_RT_ID, 9999)
    CHANGE_CONTEXTS(EFFECTIVE_DATE = L_EFF_DATE, BUSINESS_GROUP_ID = L_BG_ID, ACTY_BASE_RT_ID = L_ABRT_ID )
    l_rate_multiplier = BEN_ABR_NAME
    RETURN l_rate_multiplier

    I used DBI - BEN_ABR_NAME.
    What is back end query ? can we use query to extract the value in Extracts ?

  • [svn:bz-4.0.0_fixes] 20615: fixing the regression failure caused by the nest collection level fix, an actionscript type without remote alias will resolved as " className", we should filter out the special case

    Revision: 20615
    Revision: 20615
    Author:   [email protected]
    Date:     2011-03-04 12:11:09 -0800 (Fri, 04 Mar 2011)
    Log Message:
    fixing the regression failure caused by the nest collection level fix, an actionscript type without remote alias will resolved as ">className", we should filter out the special case
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.java

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Issue with xsd Data type mapping for collection of user defined data type

    Hi,
    I am facing a issue with wsdl for xsd mapping for collection of user defined data type.
    Here is the code snippet.
    sample.java
    @WebMethod
    public QueryPageOutput AccountQue(QueryPageInput qpInput)
    public class QueryPageInput implements Serializable, Cloneable
    protected Account_IO fMessage = null;
    public class QueryPageOutput implements Serializable, Cloneable
    protected Account_IO fMessage = null;
    public class Account_IO implements Serializable, Cloneable {
    protected ArrayList <AccountIC> fintObjInst = null;
    public ArrayList<AccountIC>getfintObjInst()
    return (ArrayList<AccountIC>)fintObjInst.clone();
    public void setfintObjInst(AccountIC val)
    fintObjInst = new ArrayList<AccountIC>();
    fintObjInst.add(val);
    Public class AccountIC
    protected String Name;
    protected String Desc;
    public String getName()
    return Name;
    public void setName(String name)
    Name = name;
    For the sample.java code, the wsdl generated is as below:
    <?xml version="1.0" encoding="UTF-8" ?>
    <wsdl:definitions
    name="SimpleService"
    targetNamespace="http://example.org"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://example.org"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    >
    <wsdl:types>
    <xs:schema version="1.0" targetNamespace="http://examples.org" xmlns:ns1="http://example.org/types"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://example.org/types"/>
    <xs:element name="AccountWSService" type="ns1:accountEMRIO"/>
    </xs:schema>
    <xs:schema version="1.0" targetNamespace="http://example.org/types" xmlns:ns1="http://examples.org"
    xmlns:tns="http://example.org/types" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:import namespace="http://examples.org"/>
    <xs:complexType name="queryPageOutput">
    <xs:sequence>
    <xs:element name="fSiebelMessage" type="tns:accountEMRIO" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="accountEMRIO">
    <xs:sequence>
    <xs:element name="fIntObjectFormat" type="xs:string" minOccurs="0"/>
    <xs:element name="fMessageType" type="xs:string" minOccurs="0"/>
    <xs:element name="fMessageId" type="xs:string" minOccurs="0"/>
    <xs:element name="fIntObjectName" type="xs:string" minOccurs="0"/>
    <xs:element name="fOutputIntObjectName" type="xs:string" minOccurs="0"/>
    <xs:element name="fintObjInst" type="xs:anyType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="queryPageInput">
    <xs:sequence>
    <xs:element name="fPageSize" type="xs:string" minOccurs="0"/>
    <xs:element name="fSiebelMessage" type="tns:accountEMRIO" minOccurs="0"/>
    <xs:element name="fStartRowNum" type="xs:string" minOccurs="0"/>
    <xs:element name="fViewMode" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.org" xmlns:ns1="http://example.org/types">
    <import namespace="http://example.org/types"/>
    <xsd:complexType name="AccountQue">
    <xsd:sequence>
    <xsd:element name="arg0" type="ns1:queryPageInput"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="AccountQue" type="tns:AccountQue"/>
    <xsd:complexType name="AccountQueResponse">
    <xsd:sequence>
    <xsd:element name="return" type="ns1:queryPageOutput"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="AccountQueResponse" type="tns:AccountQueResponse"/>
    </schema>
    </wsdl:types>
    <wsdl:message name="AccountQueInput">
    <wsdl:part name="parameters" element="tns:AccountQue"/>
    </wsdl:message>
    <wsdl:message name="AccountQueOutput">
    <wsdl:part name="parameters" element="tns:AccountQueResponse"/>
    </wsdl:message>
    <wsdl:portType name="SimpleService">
    <wsdl:operation name="AccountQue">
    <wsdl:input message="tns:AccountQueInput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
    ns1:Action=""/>
    <wsdl:output message="tns:AccountQueOutput" xmlns:ns1="http://www.w3.org/2006/05/addressing/wsdl"
    ns1:Action=""/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="SimpleServiceSoapHttp" type="tns:SimpleService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="AccountQue">
    <soap:operation soapAction=""/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="SimpleService">
    <wsdl:port name="SimpleServicePort" binding="tns:SimpleServiceSoapHttp">
    <soap:address location="http://localhost:7101/WS-Project1-context-root/SimpleServicePort"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
    In the above wsdl the collection of fintObjInst if of type xs:anytype. From the wsdl, I do not see the xsd mapping for AccountIC which includes Name and Desc. Due to which, when invoking the web service from a different client like c#(by creating proxy business service), I am unable to set the parameters for AccountIC. I am using JAX-WS stack and WLS 10.3. I have already looked at blog http://weblogs.java.net/blog/kohlert/archive/2006/10/jaxws_and_type.html but unable to solve this issue. However, at run time using a tool like SoapUI, when this wsdl is imported, I am able to see all the params related to AccountIC class.
    Can some one help me with this.
    Thanks,
    Sudha.

    Did you try adding the the XmlSeeAlso annotation to the webservice
    @XmlSeeAlso({<package.name>.AccountIC.class})
    This will add the schema for the data type (AccountIC) to the WSDL.
    Hope this helps.
    -Ajay

  • You cannot use this transaction type to post to this asset Message no.AA834

    Hi,
    I am settling credit values -ve values from WBS to Asset Under Constructions Assets during CJ88 period settlement run.
    These assets belongs to Investment Measure. For few assets I am getting below error and
    You cannot use this transaction type to post to this asset
    Message no. AA834
    Diagnosis
    The transaction type entered belongs to transaction type group 15. According to the specifications for this transaction type group, posting with transactions types belonging to this group are only allowed in specific asset classes (for example, asset classes for assets under construction).
    The asset to which you are posting belongs to class XXXXX (chart of depreciation XXXX). You cannot post to this class using the transaction type you have entered.
    Procedure
    Check the asset number entered. You may want to allow posting with this transaction type group for the asset class of the asset.
    I know normally we do this way
    During charging
    Dr Exp A/c WBS name
    Cr B.S A/c
    During settlement
    Cr Exp A/c WBS name
    Dr AuC GL A/c
    But we have situation that during settlement, we are doing reverse
    ie., Cr AuC GL A/c
    Dr Exp A/c WBS Name
    These expenses are through POs and no downpayments. The below error taking me to down payment accounts config but we dont have down payment scenario, can any one advise, thanks
    Regards,
    Sridhar

    When you have an investment order/WBS create from there the AUC. You collect the cost on the AUC. Final you fill in the settlement rule the final asset in (from a normal asset class) and then you transfer the costs to the final asset.
    In the IO or WBS should be assigened a investment profile and the asset class AUC should be set-up correct
    Search on this forum for more information or read the SAP help

  • Error 136 Functions that can be compossed must declare a return type

    Hello,
    I have downloaded the EF Final Release driver and Im working with Oracle 11g express.
    I have the following Procedure:
    PROCEDURE ProductosPedido(
    Datos Out SYS_RefCursor) IS
    BEGIN
    OPEN Datos FOR
    SELECT Nombre,
    TO_NUMBER(Precio * (SELECT SUM(unidades)
    FROM DETALLES_PEDIDO
    WHERE PRODUCTO = PRODUCTO.ID)) Importe
    FROM PRODUCTO;
    END;
    And the following config section:
    <oracle.dataaccess.client>
    <settings>
    <add name="System.Productospedido.RefCursor.Datos" value="implicitRefCursor bindinfo='mode=Output'"/>
    <add name="System.Productospedido.RefCursorMetaData.Datos.Column.0" value="implicitRefCursor metadata='ColumnName=Nombre;BaseColumnName=Nombre;BaseSchemaName=System;BaseTableName=Producto;NativeDataType=nvarchar2;ProviderType=NVarchar2;DataType=System.String;ColumnSize=50;AllowDBNull=true;IsKey=false'" />
    <add name="System.Productospedido.RefCursorMetaData.Datos.Column.1" value="implicitRefCursor metadata='ColumnName=Importe;NativeDataType=number;ProviderType=Decimal;DataType=System.Decimal;AllowDBNull=false;IsKey=false;ColumnSize=8'" />
    </settings>
    </oracle.dataaccess.client>
    I have imported succesfully in my EF Model, but when I try to consume the Procedure it gives me Error 136 Functions that can be compossed must declare a return type
    Any solutions?
    Thanks and best regards!

    A stored procedure does not have a ReturnType, therefore IsComposable="false" and it cannot be used in LINQ queries.
    This limitation is imposed by EF and not by ODP.
    You may want to create a stored function which has a ReturnType ref cursor, and include this stored function into your model. Then, under the same namespace, you create a class with a "stub" method/function and use EdmFunction() to map this stub to the stored function. For example,
    class myFuncClass
    [EdmFunction("Model.Store", "MY_STORED_FUNC_1")]
    public static <your_complex_type_or_DbDataRecord> MyFunc_1(int? column1, ...)
    throw new NotSupportedException("Direct calls are not supported");
    You should be able to call myFuncClass.MyFunc_1(x) in your LINQ query. Your stored function MY_STORED_FUNC_1 will be called in the generated query.

Maybe you are looking for

  • Doubts in GeoRaster Concept.

    Hi everybody, I have few doubts in GeoRaster concepts. I did mosaicing of multiple Georasater objects using "sdo_geor.getRasterSubset()" and able to display image properly. But while doing this I come across few people suggestions. They said that mos

  • I would like to know how I can service my battery online.

    I would like to know how I can service my battery online?

  • How to improve jdbc 4 connection and Transact-SQL

    I am using a jdbc 4 connection to connect to Database. With code Class.forName("org.postgresql.Driver"); String url = "jdbc:msql://athens.imaginary.com:4333/db_web"; username = �mycon�; password = �mycon�; Connection  conn = DriverManager.getConnecti

  • External HD workflow

    Hi there, New to FCP X I have important things to understand for me workflow wise. I guess the best way to work is to import, footage, work from and save directly to an external HD. If not please tell me otherwise. Right now I have footage both on my

  • Help my ipad is giving trouble

    for some odd reason my ipad wont turn off the screen is blank with the circular thingy in the middle