ClassCastException extent.close(iterator)

I'm doing something like the following:
Extent ext = commonManager.getExtent(c, includeSubClasses);
Query query = commonManager.newQuery(ext);
Iterator it = ((Collection)query.execute()).iterator();
//iterate over instances
query.close(it);
ext.close(it);
With or without the query.close I get a classcastexception in
ExtentImpl.close: 169
com.solarmetric.kodo.runtime.FatalInternalException:
java.lang.ClassCastException
NestedThrowables:
java.lang.ClassCastException
at com.solarmetric.kodo.runtime.ExtentImpl.close(ExtentImpl.java:169)
This is version 2.5.5. Am I doing something wrong?
Dylan

Dylan-
I believe the offending line is:
ext.close(it);The only Iterators you should pass to Extent.close() are ones that were
created from the Extent.iterator() method, not ones that are created
from query execution.
I think the thing you want to do is:
Extent ext = commonManager.getExtent(c, includeSubClasses);
Query query = commonManager.newQuery(ext);
Collection results = (Collection).query.execute();
Iterator it = results.iterator();
// iterate over instances
query.close(results);
Or, more simply:
Extent ext = commonManager.getExtent(c, includeSubClasses);
Query query = commonManager.newQuery(ext);
Iterator it = ((Collection)query.execute()).iterator();
// iterate over instances
query.closeAll();
In article <bq0e20$50a$[email protected]>, D. Wilson wrote:
I'm doing something like the following:
Extent ext = commonManager.getExtent(c, includeSubClasses);
Query query = commonManager.newQuery(ext);
Iterator it = ((Collection)query.execute()).iterator();
//iterate over instances
query.close(it);
ext.close(it);
With or without the query.close I get a classcastexception in
ExtentImpl.close: 169
com.solarmetric.kodo.runtime.FatalInternalException:
java.lang.ClassCastException
NestedThrowables:
java.lang.ClassCastException
at com.solarmetric.kodo.runtime.ExtentImpl.close(ExtentImpl.java:169)
This is version 2.5.5. Am I doing something wrong?
Dylan
Marc Prud'hommeaux [email protected]
SolarMetric Inc. http://www.solarmetric.com

Similar Messages

  • ClassCastException with Query

    This simple query gives me a ClassCastException:
    Extent users = pm.getExtent (User.class, false);
    String filter = "userid == \"test_michael\"";
    Query query = pm.newQuery (users, filter);
    Collection results = (Collection) query.execute ();
    From the log, the SQL generated looks correct. I'm not using any
    inheritance, so I don't see how I could get a ClassCastException.
    [ C:27826089; S:22238933; T:20754125; D:18/09/02 12:02 ] SELECT t0.JDOIDX,
    t0.JDOCLASSX, t0.JDOLOCKX, t0.COMPANYX, t0.PASSWORDX, t0.USERIDX FROM USERX
    t0 WHERE t0.USERIDX = 'test_michael'
    Exception = javax.jdo.JDOFatalDataStoreException: javax.jdo.JDOException:
    java.lang.ClassCastException
    NestedThrowables:
    java.lang.ClassCastException
    NestedThrowables:
    javax.jdo.JDOException: java.lang.ClassCastException
    NestedThrowables:
    java.lang.ClassCastException

    I totally deleted my hashCode() & equals() methods in my object and now it
    works. I'm really confused about writing hashCode & equals.
    "Michael" <[email protected]> a __crit dans le message de news:
    [email protected]...
    Here is a stack trace:
    java.lang.ClassCastException
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(LazyRes
    ultList.java:186)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(LazyResultList.jav
    a:114)
    at java.util.AbstractList$Itr.next(AbstractList.java:416)
    at
    com.solarmetric.kodo.runtime.ResultListIterator.next(ResultListIterator.java
    :49)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Re
    sultListFactory.java:85)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
    reManager.java:646)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java
    :150)
    atcom.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:580)
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:428)
    at
    com.solarmetric.kodo.query.QueryImpl$SynchronizedQuery.execute(QueryImpl.jav
    a:1334)
    at
    com.idtect.oemserver.persistence.TestUser.removeTestUser(TestUser.java:75)
    at com.idtect.oemserver.persistence.TestUser.tearDown(TestUser.java:44)
    at junit.framework.TestCase.runBare(TestCase.java:143)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
    nner.java:326)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
    java:215)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
    .java:148)
    NestedThrowablesStackTrace:
    javax.jdo.JDOException: java.lang.ClassCastException
    NestedThrowables:
    java.lang.ClassCastException
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
    istenceManagerImpl.java:874)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
    eManagerImpl.java:785)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.createFromResultSet(
    JDBCStoreManager.java:700)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager$2.getResultObject(JD
    BCStoreManager.java:652)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(LazyRes
    ultList.java:168)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(LazyResultList.jav
    a:114)
    at java.util.AbstractList$Itr.next(AbstractList.java:416)
    at
    com.solarmetric.kodo.runtime.ResultListIterator.next(ResultListIterator.java
    :49)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Re
    sultListFactory.java:85)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
    reManager.java:646)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java
    :150)
    atcom.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:580)
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:428)
    at
    com.solarmetric.kodo.query.QueryImpl$SynchronizedQuery.execute(QueryImpl.jav
    a:1334)
    at
    com.idtect.oemserver.persistence.TestUser.removeTestUser(TestUser.java:75)
    at com.idtect.oemserver.persistence.TestUser.tearDown(TestUser.java:44)
    at junit.framework.TestCase.runBare(TestCase.java:143)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
    nner.java:326)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
    java:215)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
    .java:148)
    NestedThrowablesStackTrace:
    java.lang.ClassCastException
    at com.idtect.domain.User.jdoCopyKeyFieldsFromObjectId(User.java)
    at com.idtect.domain.User.jdoNewInstance(User.java)
    at javax.jdo.spi.JDOImplHelper.newInstance(Unknown Source)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.loadPrimaryMappings(
    JDBCStoreManager.java:401)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.initialize(JDBCStore
    Manager.java:236)
    at
    com.solarmetric.kodo.runtime.StateManagerImpl.loadInitialState(StateManagerI
    mpl.java:112)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectByIdFilter(Pers
    istenceManagerImpl.java:863)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.getObjectById(Persistenc
    eManagerImpl.java:785)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.createFromResultSet(
    JDBCStoreManager.java:700)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager$2.getResultObject(JD
    BCStoreManager.java:652)[ C:5618579; T:26094370; D:18/09/02 13:21 ] close:
    jdbc:postgresql://localhost:5432/jdotest (michael)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.instantiateRow(LazyRes
    ultList.java:168)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.LazyResultList.get(LazyResultList.jav
    a:114)
    at java.util.AbstractList$Itr.next(AbstractList.java:416)
    at
    com.solarmetric.kodo.runtime.ResultListIterator.next(ResultListIterator.java
    :49)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.ResultListFactory.createResultList(Re
    sultListFactory.java:85)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
    reManager.java:646)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCQuery.executeQuery(JDBCQuery.java
    :150)
    atcom.solarmetric.kodo.query.QueryImpl.executeWithMap(QueryImpl.java:580)
    at com.solarmetric.kodo.query.QueryImpl.execute(QueryImpl.java:428)
    at
    com.solarmetric.kodo.query.QueryImpl$SynchronizedQuery.execute(QueryImpl.jav
    a:1334)
    at
    com.idtect.oemserver.persistence.TestUser.removeTestUser(TestUser.java:75)
    at com.idtect.oemserver.persistence.TestUser.tearDown(TestUser.java:44)
    at junit.framework.TestCase.runBare(TestCase.java:143)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:131)
    at junit.framework.TestSuite.runTest(TestSuite.java:173)
    at junit.framework.TestSuite.run(TestSuite.java:168)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
    nner.java:326)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
    java:215)
    at
    org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
    .java:148)

  • 'invalid column' in nested iterator

    hello,
    I am facing problm 'nvalid coumn' in a example of nested
    iterator given in the online documentation.
    The part of the code is as below:
    #sql public iterator DNameIter (String dname);
    #sql pubic iterator NameDeptIter2 (String ename, DNameIter
    depts);
    import DNameIter;
    import NameDeptIter2;
    Executable code:
    NameDeptIter2 iter;
    // the query below is causing the error
    #sql iter = { SELECT ename, cursor
    (SELECT dname FROM dept WHERE deptno = emp.deptno)
    AS depts FROM emp };
    while (iter.next())
    System.out.println(iter.ename());
    DNameIter deptsIter = iter.depts();
    while (deptsIter.next())
    System.out.println(deptsIter.dname());
    deptsIter.close();
    iter.close();
    please reply
    thanks
    vidya
    null

    Hi,
    U r refering to emp table which is not in that scope.
    try with the following statement it works ...
    #sql iter = { SELECT a.ename,
    CURSOR(SELECT dname FROM dept
    WHERE deptno = a.deptno)
    AS depts FROM emp a };
    Bye
    Mohan E
    vidya (guest) wrote:
    : hello,
    : I am facing problm 'nvalid coumn' in a example of nested
    : iterator given in the online documentation.
    : The part of the code is as below:
    : #sql public iterator DNameIter (String dname);
    : #sql pubic iterator NameDeptIter2 (String ename, DNameIter
    : depts);
    : import DNameIter;
    : import NameDeptIter2;
    : Executable code:
    : NameDeptIter2 iter;
    : // the query below is causing the error
    : #sql iter = { SELECT ename, cursor
    : (SELECT dname FROM dept WHERE deptno = emp.deptno)
    : AS depts FROM emp };
    : while (iter.next())
    : System.out.println(iter.ename());
    : DNameIter deptsIter = iter.depts();
    : while (deptsIter.next())
    : System.out.println(deptsIter.dname());
    : deptsIter.close();
    : iter.close();
    : please reply
    : thanks
    : vidya
    null

  • Subform ceases to open after toggling open/close 3rd time

    I have a Yes/No radio button that controls the visibility of a subform on a multi-page doc. The subform (named: Chapter) is the last subform on the page. When Yes is selected, it reveals the default hidden "Chapter "subform, while clicking "No" hides it. After 3-4 open/close iterations, the subform suddenly fails to open after clicking “Yes” again.
    What's weird is that you can the subform is being rendered (behind the scenes) because the Page number in the footer increases by 1 to signify content has been added to the document, HOWEVER, the subform doesn't become visible, nor can I scroll down to view the page where it would/should have opened.
    Simply put, I'm using a radio button on the Change event with the following script:
    if (this.rawValue == "1"){
    Chapter.presence = "visible";
    if (this.rawValue == "2"){
    Chapter.presence = "hidden";
    Again, the script works for the most part but it all of sudden stops opening the subform after the 3rd or 4th attempt. It almost seems like some type of system bug that's REALLY annoying given how simple this is...
    Other info:
    - I'm using Designer ES2
    - Form has a target version of 9.0/9.1
    - Using Acrobat XI to render form outside of Livecycle
    - The Chapter subform contain other nested subforms, and is set to "Follow Previous" and also Allowed to Page break within Content.
    Any ideas what could be causing this to happen???

    Did you ever get anywhere with this? I have the same issue and nobody in #winehq knows what to do about it.
    Steam community disabled, and this issue has been happening for several Wine versions, across several Nvidia drivers.

  • Error while deploying a project to the OBPM 10GR3 Server

    Hi all,
    I am trying to deploy my current project to the OBPM 10GR3 server and it gives me the following exception. I am not sure what is this exception.
    The project compiles well in Studio 10GR3.
    Cannot publish the project.
    'close' is not a function. Caused by: 'close' is not a function.
    Does anybody know what is the exception?

    Got it..
    I was using Fuego.Sql.DynamicSQL.close(Iterator)
    For a an executeUpdate query which returns an int.
    But I used it in a method and did not use that method inside my process or screenflow.
    But it did not give me any error/exception while compiling it in Studio.
    It gave me an exception while publishing in Enterprise.
    This is strange.
    It should have given me an error/exception while compiling itself rather than while publishing in Enterprise.

  • Internal Server Error while deploying a project to a remote BPEL instance.

    Some background. We were trying to use the adapters going out through iWay to hit a Siebel instance. Originally, we were using a BPEL VM for development, and trying to hit adapters on the iWay box. We found out that we needed to have BPEL and adapters installed in the OC4J container; so we rebuilt our iWay box.
    So, now the iWay box has Oracle DB, Oracle App Server, BPEL, and adapters in the same OC4J container.
    When you do an appserver install of BPEL, it doesn't install JDev; so we are doing development on our BPEL VM; or on a standalone version on the laptop (both give the same error.)
    I can deploy the project locally to my laptop or the locally to the SOA(BPEL) VM, but when I try to deploy from either JDev to the BPEL server on iWay, we get:
    Beginning Deployment Process...
    Compiling C:\OraBPELPM_1\integration\jdev\jdev\mywork\AJ_Siebel\OracleCDHToSiebelAsyncCustomer\OracleCDHToSiebelAsyncCustomer.bpel
    Compiling...
    BPEL suitcase generated in: C:\OraBPELPM_1\integration\jdev\jdev\mywork\AJ_Siebel\OracleCDHToSiebelAsyncCustomer\output\bpel_OracleCDHToSiebelAsyncCustomer_1.0.jar
    [1:55:05 PM] Successful compilation: 0 errors, 0 warnings.
    Deploying to http://148.87.129.102:80 domain: default. Please wait....
    [1:55:15 PM] Deployment failed.
    Description of problem: Server error.Internal Server Error
    Suggested solution: Please report this error to the adminsitrator.
    I can hit the BPEL console on the http://148.87.129.102:80/BPELConsole link, so I know that's correct... (as well as the "Test Connection" works fine to that box.)
    Anyone seen this before? Ideas?

    Got it..
    I was using Fuego.Sql.DynamicSQL.close(Iterator)
    For a an executeUpdate query which returns an int.
    But I used it in a method and did not use that method inside my process or screenflow.
    But it did not give me any error/exception while compiling it in Studio.
    It gave me an exception while publishing in Enterprise.
    This is strange.
    It should have given me an error/exception while compiling itself rather than while publishing in Enterprise.

  • Trying to access an object's field but it has private access ! !

    Dear People,
    I am trying to access the highestBid, a data member of the Bid class
    in an Auction program.
    If I try to set the highestBid:
    bicycle.setHighestBid(steveBicycleBid);
    The error message says:
    "TryAuction.java": Error #: 306 : method setHighestBid(stan_bluej_ch4p90.Bid) has private access in class stan_bluej_ch4p90.Lot at line 58, column 15
    IF I try to get the highest bid by saying:
    System.out.println("The highest bid for this item is " + bicycle.getHighestBid() );
    I get an object hex address as seen below instead of an integer value:
    The highest bid for this item is stan_bluej_ch4p90.Bid@f4a24a
    ^^^
    Below are the classes
    Thank you in advance
    stan
    package stan_bluej_ch4p90;
    //Purpose of project: To demonstrate collections of objects
    //Version: 2001.05.31
    //How to start this project:
    // Create an Auction object.
    // Enter a few lots via its enterLot method. Only String
    // descriptions of the lots are required.
    // Create one or more Person objects to represent bidders.
    // Show the lots and select one to bid for.
    // Get the required Lot onto the object bench.
    // Enter a bid for the lot, passing the Person who is
    // bidding to the bidFor method.
    public class TryAuction
    public static void main(String[] args)
    //create the auction
    Auction cityAuction = new Auction();
    //create the lots for sale
    Lot bicycle = new Lot(1,"bicycle");
    Lot lamp = new Lot(2, "lamp");
    Lot trailer = new Lot(3, "trailer");
    //enter the lots into the city Auction
    cityAuction.enterLot("A bicycle in so so condition");
    cityAuction.enterLot("A brand new lamp");
    cityAuction.enterLot("A trailer built in 2001");
    //show the lots
    System.out.println();
    System.out.println("The first lot for sale: " + bicycle.getDescription());
    System.out.println("The second lot for sale: " + lamp.getDescription());
    System.out.println("The third lot for sale: " + trailer.getDescription());
    //create the people who will bid for the lots
    Person Steve = new Person("Steve");
    Person Maria = new Person("Maria");
    //create the people's bids
    Bid mariaLampBid = new Bid(Maria, 460);
    Bid steveLampBid = new Bid(Steve, 510);
    //create the people's bids
    Bid mariaBicycleBid = new Bid(Maria, 1460);
    Bid steveBicycleBid = new Bid(Steve, 1510);
    //create the people's bids
    Bid steveTrailerBid = new Bid(Steve, 700510);
    Bid mariaTrailerBid = new Bid(Maria, 900460);
    //give the bids
    bicycle.bidFor(Maria,1460);
    bicycle.bidFor(Steve, 1510);
    //bicycle.setHighestBid(steveBicycleBid);
    System.out.println("The highest bid for this item is " + bicycle.getHighestBid() );
    lamp.bidFor(Maria,460);
    lamp.bidFor(Steve,510);
    trailer.bidFor(Steve, 700510);
    trailer.bidFor(Maria,900460);
    System.out.println(" \nMaria's bicycle bid is : " + mariaBicycleBid.getValue() );
    System.out.println("Steve's lamp bid is : " + steveBicycleBid.getValue() );
    System.out.println(" \nMaria's lamp bid is : " + mariaLampBid.getValue() );
    System.out.println("Steve's lamp bid is : " + steveLampBid.getValue() );
    System.out.println("\nSteve's trailer bid is : " + steveTrailerBid.getValue() );
    System.out.println(" Maria's trailer bid is : " + mariaTrailerBid.getValue() );
    System.out.println();
    cityAuction.showLots();
    //cityAuction.close();
    //The output I get is:
    //The first lot for sale: bicycle
    //The second lot for sale: lamp
    //The third lot for sale: trailer
    //The highest bid for this item is stan_bluej_ch4p90.Bid@f4a24a
    //Maria's bicycle bid is : 1460
    //Steve's lamp bid is : 1510
    //Maria's lamp bid is : 460
    //Steve's lamp bid is : 510
    //Steve's trailer bid is : 700510
    // Maria's trailer bid is : 900460
    //1: A bicycle in so so condition
    // (No bid)
    //2: A brand new lamp
    // (No bid)
    //3: A trailer built in 2001
    // (No bid)
    package stan_bluej_ch4p90;
    import java.util.*;
    //Ex4.14
    * A simple model of an auction.
    * The auction maintains a list of lots of arbitrary length.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.06.08
    public class Auction
    // The list of Lots in this auction.
    private ArrayList lots;
    // The number that will be given to the next lot entered
    // into this auction.
    private int nextLotNumber;
    * Create a new auction.
    public Auction()
         lots = new ArrayList();
         nextLotNumber = 1;
    * Enter a new lot into the auction.
    * Lots can only by entered into the auction by an
    * Auction object.
    * @param description A description of the lot.
    public void enterLot(String description)
         lots.add(new Lot(nextLotNumber, description));
         nextLotNumber++;
    * Show the full list of lot numbers and lot descriptions in
    * this auction. Include any details of the highest bids.
    public void showLots()
         Iterator it = lots.iterator();
         while(it.hasNext()) {
         Lot lot = (Lot) it.next();
         System.out.println(lot.getNumber() + ": " +
                   lot.getDescription());
         // Include any details of a highest bid.
         Bid highestBid = lot.getHighestBid();
         if(highestBid != null) {
              System.out.println(" Bid: " +
                        highestBid.getValue());
         else {
              System.out.println(" (No bid)");
    * Return the lot with the given number. Return null
    * if a lot with this number does not exist.
    * @param number The number of the lot to return.
    public Lot getLot(int number)
         if((number >= 1) && (number < nextLotNumber)) {
         // The number seems to be reasonable.
         Lot selectedLot = (Lot) lots.get(number-1);
         // Include a confidence check to be sure we have the
         // right lot.
         if(selectedLot.getNumber() != number) {
              System.out.println("Internal error: " +
                        "Wrong lot returned. " +
                        "Number: " + number);
         return selectedLot;
         else {
         System.out.println("Lot number: " + number + " does not exist.");
         return null;
    // public void close()
    // Iterator i = lots.iterator();
    // while(i.hasNext())
    //     System.out.println("The winning amount for the " + bicycle.getDescription()
    //     + " is " + bicycle.getHighestBid());
    //     System.out.println("The winning amount for the " + lamp.getDescription()
    //     + " is " + lamp.getHighestBid());
    //     System.out.println("The winning amount for the " + trailer.getDescription()
    //     + " is " + trailer.getHighestBid());
    package stan_bluej_ch4p90;
    * A class to model an item (or set of items) in an
    * auction: a lot.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.06.08
    public class Lot
    // A unique identifying number.
    private final int number;
    // A description of the lot.
    private String description;
    // The current highest bid for this lot.
    private Bid highestBid;
    * Construct a Lot, setting its number and description.
    * @param number The lot number.
    * @param description A description of this lot.
    public Lot(int number, String description)
         this.number = number;
         this.description = description;
    * Attempt to bid for this lot. A successful bid
    * must have a value higher than any existing bid.
    * @param bidder Who is bidding.
    * @param value The value of the bid.
    public void bidFor(Person bidder, long value)
         // We trust that lot is genuine. There is nothing to
         // prevent a spurious lot from being bid for, but it
         // would not appear in the auction list.
         if((highestBid == null) ||
         (highestBid.getValue() < value)) {
         // This bid is the best so far.
         setHighestBid(new Bid(bidder, value));
         else {
         System.out.println("\nLot number: " + getNumber() +
                   " (" + getDescription() + ")" +
                   " has a bid of: " +
                   highestBid.getValue());
    * @return The lot's number.
    public int getNumber()
         return number;
    * @return The lot's description.
    public String getDescription()
         return description;
    * @return The highest bid for this lot. This could be null if
    * there are no current bids.
    public Bid getHighestBid()
         return highestBid;
    * @param highestBid The new highest bid.
    private void setHighestBid(Bid highestBid)
         this.highestBid = highestBid;
    package stan_bluej_ch4p90;
    * A class that models an auction bid. The bid contains a reference
    * to the Lot bid for and the user making the bid.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.05.31
    public class Bid
    // The user making the bid.
    private final Person bidder;
    // The value of the bid. This could be a large number so
    // the long type has been used.
    private final long value;
    * Create a bid.
    * @param bidder Who is bidding for the lot.
    * @param value The value of the bid.
    public Bid(Person bidder, long value)
         this.bidder = bidder;
         this.value = value;
    * @return The bidder.
    public Person getBidder()
         return bidder;
    * @return The value of the bid.
    public long getValue()
         return value;
    package stan_bluej_ch4p90;
    * Maintain details of someone who participates in an auction.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.05.31
    public class Person
    // The name of this user.
    private final String name;
    * Create a new user with the given name.
    * @param name The user's name.
    public Person(String name)
         this.name = name;
    * @return The user's name.
    public String getName()
         return name;
    if I try to say
    LotObjectName.getHighestBid, I get a

    Dear EsoralTrebor,
    Thank you very much for an enlightening explanation.
    I had never tried to chain methods together before but it works !
    anObject.methodOfTheObjectClassThatReturnsAnObjectOfAnotherClass.
    methodOfTheObjectClassThatWasReturned();
    my output correctly states:
    The highest bid for the bicycle is 1510
    The highest bid for the lamp is 510
    The highest bid for the trailer is 900460
    Thank you !
    Stan
    ps tomorrow I need to study the showLots() method in the Auction class
    to figure out why that method is saying "No Bid" to everything
    Have a Good Thanksgiving !

  • Urgent java problems

    Ok here's my situation... I'm having to catch up in my software development class at university, missed a few lessons so now I'm finding it incredibly difficult.
    I'm working through a bluej book 'Objects First with Java' and as much as I'd like to sit and work each question out, it is taking me far too long and I'm not gonna manage so this will probably be the first post of many.
    So here's where I am
    (pg. 110, ex. 4.28)
    It's a simple auction program that lets you create a bidder, a lot(something to bid on), an auction and of course the ability to bid.
    What I'm being asked...
    Add a close method to the Auction class. This should iterate over the collection of lots and print out details of all the lots. You can use either a for-each loop or a while loop. Any lot that has had at least one bid for it is considered to be sold. For lots that have been sold, the details should include the name of the successful bidder, and the value of the winning bid. For lots that have not been sold, print a message that indicates this fact.
    import java.util.ArrayList;
    import java.util.Iterator;
    * A simple model of an auction.
    * The auction maintains a list of lots of arbitrary length.
    * @author David J. Barnes and Michael Kolling.
    * @version 2008.03.30
    public class Auction
        // The list of Lots in this auction.
        private ArrayList<Lot> lots;
        // The number that will be given to the next lot entered
        // into this auction.
        private int nextLotNumber;
         * Create a new auction.
        public Auction()
            lots = new ArrayList<Lot>();
            nextLotNumber = 1;
         * Enter a new lot into the auction.
         * @param description A description of the lot.
        public void enterLot(String description)
            lots.add(new Lot(nextLotNumber, description));
            nextLotNumber++;
         * Show the full list of lots in this auction.
        public void showLots()
            for(Lot lot : lots) {
                System.out.println(lot.toString());
         * Bid for a lot.
         * A message indicating whether the bid is successful or not
         * is printed.
         * @param number The lot number being bid for.
         * @param bidder The person bidding for the lot.
         * @param value  The value of the bid.
        public void bidFor(int lotNumber, Person bidder, long value)
            Lot selectedLot = getLot(lotNumber);
            if(selectedLot != null) {
                boolean successful = selectedLot.bidFor(new Bid(bidder, value));
                if(successful) {
                    System.out.println("The bid for lot number " +
                                       lotNumber + " was successful.");
                else {
                    // Report which bid is higher.
                    Bid highestBid = selectedLot.getHighestBid();
                    System.out.println("Lot number: " + lotNumber +
                                       " already has a bid of: " +
                                       highestBid.getValue());
         * Return the lot with the given number. Return null
         * if a lot with this number does not exist.
         * @param lotNumber The number of the lot to return.
        public Lot getLot(int lotNumber)
            if((lotNumber >= 1) && (lotNumber < nextLotNumber)) {
                // The number seems to be reasonable.
                Lot selectedLot = lots.get(lotNumber - 1);
                // Include a confidence check to be sure we have the
                // right lot.
                if(selectedLot.getNumber() != lotNumber) {
                    System.out.println("Internal error: Lot number " +
                                       selectedLot.getNumber() +
                                       " was returned instead of " +
                                       lotNumber);
                    // Don't return an invalid lot.
                    selectedLot = null;
                return selectedLot;
            else {
                System.out.println("Lot number: " + lotNumber +
                                   " does not exist.");
                return null;
        public void close(){
            Iterator<Lot> it = lots.iterator();
            for(Lot lot : lots){
            if(lots.contains(null)){
                System.out.println(lot.toString() + " has not been sold.");
    }I know my 'close' method is a bit shoddy and doesn't utilise the iterator yet but I tested it and it compiled ok but nothing happened :/
    Is the for-each loop a wise move? Ideas would be greatly appreciated! I tried a while loop first but wasn't really getting anywhere. One of my many problems in this is that I don't really understand where the methods I'm calling from are coming from either, I really don't have a good base understanding of the language :( for instance lots.toString() where does the .toString come from, thats an arraylist method then yeah?
    I am feeling that the book is going pretty fast, some questions are fairly simple then suddenly I feel like it's never even taught me enough to even work a question out on my own - obviously just starting out at programming though so it may be completely obvious but if you don't know it you don't know it :/
    Anyway folks I hope you can help as, like I said, it's pretty important to me and I don't know how the forum works but if I'm the one that will have the power to award the points for an answer then I will deal them out appropriately.
    Cheers
    Edited by: jpjenkins on Nov 14, 2008 2:00 AM

    jpjenkins wrote:
    Wow what a nice introduction to the forum.
    My time management skills are good, thanks for the advice though. We must have a different notion of what the word "good" means...
    But how can I be 'all high an mighty' It sounded like you were doing us a favor by handing out some forum/duke points/stars while you are the one looking for help.
    when I said I don't know how the forum works, sounds like you've got a complex man, was just trying to let peeps know I was going to be fair.Wow, your assessment of my psychic state is impressive! By studying your two posts here, I conclude you're a lazy twit.
    I do apologise however, I wrote this after 3 hours of studying and my stress must have transferred into the post.Then study some more!
    To the point: "I tested it and it compiled ok but nothing happened :/ " - I just wanted to know where I had gone wrong in the close method as I expected it to print out a lot that doesn't have a bid on it.
    I have worked through the book at a steady pace, I simply don't have the luxury to sit and work out where I had gone wrong in each question, sorry if I misled you into thinking I expected you to do it for me, these aren't necessary questions for me to do, they're just giving me a good grounding for my project which has to be handed in on the 5th of December. Trying to speed my workrate up by getting advice on my shoddy code.
    Hope someone can helpI still don't see a specific question.

  • Accessing objects after closing the PersistenceManager

    I have a session bean which returns a collection of objects obtained from a
    query. The problem is if I close my PersistenceManager in the session bean
    method, I can't access the objects. What will happen if I don't close it?
    Won't I have a memory leak? I'm curious if I'm missing something. Here is
    my code, I cut out most of it. The println's work fine if I comment out the
    pm.close().
    public Collection searchFlights(AirportCode from, AirportCode to, Calendar
    calendar, int passengers) {
    PersistenceManager pm = null;
    try {
    pm = factory.getPersistenceManager();
    c = (Collection) q.executeWithMap(p);
    } finally {
    pm.close();
    Iterator i = c.iterator();
    while (i.hasNext()) {
    System.out.println("Flight = " + (Flight) i.next());
    return c;

    Michael-
    Firstly, you do not need to obtain and close the PersistenceManager in
    each method if you are using a stateful session bean. However, if you
    are using a stateless session bean, section 16.1.1 mandates:
    At the end of the business method, the PersistenceManager instance
    must be closed. This allows the transaction completion code in the
    PersistenceManager to free the instance and return it to the
    available pool in the PersistenceManagerFactory.
    Now, as it happens, we don't pool PersistenceManagers, and I am fairly
    sure that it would work fine if you didn't close it, but it is always
    good to respect the spec when writing portable code.
    I suspect that the problem that you might be seeing is that your session
    bean is serializing the Collection to return to the client. Note that
    the full closure of serializable fields can wind up being a huge
    performance hit (e.g., the entire object graph in the database may be
    instantiated). Bear this in mind when your code is serializing a PC.
    To get around the problem, you could throw in a quick serialization
    right before you close the PM. E.g.:
    new ObjectOutputStream (new ByteArrayOutputStream ()).writeObject (c);
    This will be a performance hit, but I doubt that it will be any more so
    than sending the entire serialized graph over the network.
    In article <[email protected]>, Michael wrote:
    I have a session bean which returns a collection of objects obtained from a
    query. The problem is if I close my PersistenceManager in the session bean
    method, I can't access the objects. What will happen if I don't close it?
    Won't I have a memory leak? I'm curious if I'm missing something. Here is
    my code, I cut out most of it. The println's work fine if I comment out the
    pm.close().
    public Collection searchFlights(AirportCode from, AirportCode to, Calendar
    calendar, int passengers) {
    PersistenceManager pm = null;
    try {
    pm = factory.getPersistenceManager();
    c = (Collection) q.executeWithMap(p);
    } finally {
    pm.close();
    Iterator i = c.iterator();
    while (i.hasNext()) {
    System.out.println("Flight = " + (Flight) i.next());
    return c;
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • HOW TO SET  VARIABLE WHEN METHOD HAS PRIVATE ACCESS ? ?

    Dear People,
    When I try to use an if then else statement the if part is not executed
    only the else
    if(highestBid != null)
    System.out.println( Bid is: + highestBid.getValue());
    else
    System.out.println(" (no bid) )";
    which can only mean that "highestBid is not being set
    but since "Class Lot" has a private method
    private void setHighestBid(Bid highestBid)
    this.highestBid = highestBid;
    the error message says:
    "TryAuction.java": Error method setHighestBid()
    has private access in class
    so how do I get a value to "highestBid" so the "if" statement
    will have a vaule for "highestBid ?
    the showLots() method in the Class "Auction" doesn't print out the bids !
    below are the classes
    thank you in advance
    Stan
    package stan_bluej_ch4p90;
    //Purpose of project: To demonstrate collections of objects
    //Version: 2001.05.31
    //How to start this project:
    // Create an Auction object.
    // Enter a few lots via its enterLot method. Only String
    // descriptions of the lots are required.
    // Create one or more Person objects to represent bidders.
    // Show the lots and select one to bid for.
    // Get the required Lot onto the object bench.
    // Enter a bid for the lot, passing the Person who is
    // bidding to the bidFor method.
    public class TryAuction
    public static void main(String[] args)
    //create the auction
    Auction cityAuction = new Auction();
    //create the lots for sale
    Lot bicycle = new Lot(1,"bicycle");
    Lot lamp = new Lot(2, "lamp");
    Lot trailer = new Lot(3, "trailer");
    //enter the lots into the city Auction
    cityAuction.enterLot("A bicycle in so so condition");
    cityAuction.enterLot("A brand new lamp");
    cityAuction.enterLot("A trailer built in 2001");
    //show the lots
    System.out.println();
    System.out.println("The first lot for sale: " + bicycle.getDescription());
    System.out.println("The second lot for sale: " + lamp.getDescription());
    System.out.println("The third lot for sale: " + trailer.getDescription());
    //create the people who will bid for the lots
    Person Steve = new Person("Steve");
    Person Maria = new Person("Maria");
    //create the people's bids
    Bid mariaLampBid = new Bid(Maria, 460);
    lamp.setHighestBid(mariaLampBid);
    Bid steveLampBid = new Bid(Steve, 510);
    //create the people's bids
    Bid mariaBicycleBid = new Bid(Maria, 1460);
    //bicycle.setHighestBid(mariaBicycleBid);
    Bid steveBicycleBid = new Bid(Steve, 1510);
    //create the people's bids
    Bid steveTrailerBid = new Bid(Steve, 700510);
    //trailer.setHighestBid(steveTrailerBid);
    Bid mariaTrailerBid = new Bid(Maria, 900460);
    //give the bids
    bicycle.bidFor(Maria,1460);
    bicycle.bidFor(Steve, 1510);
    System.out.println("The highest bid for the bicycle is " + bicycle.getHighestBid().getValue() );
    lamp.bidFor(Maria,460);
    lamp.bidFor(Steve,510);
    System.out.println("The highest bid for the lamp is " + lamp.getHighestBid().getValue() );
    trailer.bidFor(Steve, 700510);
    trailer.bidFor(Maria,900460);
    System.out.println("The highest bid for the trailer is " + trailer.getHighestBid().getValue() );
    System.out.println(" \nMaria's bicycle bid is : " + mariaBicycleBid.getValue() );
    System.out.println("Steve's bicycle bid is : " + steveBicycleBid.getValue() );
    System.out.println(" \nMaria's lamp bid is : " + mariaLampBid.getValue() );
    System.out.println("Steve's lamp bid is : " + steveLampBid.getValue() );
    System.out.println("\nSteve's trailer bid is : " + steveTrailerBid.getValue() );
    System.out.println(" Maria's trailer bid is : " + mariaTrailerBid.getValue() );
    System.out.println();
    cityAuction.showLots();
    //cityAuction.close();
    //The output I get is:
    //The first lot for sale: bicycle
    //The second lot for sale: lamp
    //The third lot for sale: trailer
    //The highest bid for this item is stan_bluej_ch4p90.Bid@f4a24a
    //Maria's bicycle bid is : 1460
    //Steve's lamp bid is : 1510
    //Maria's lamp bid is : 460
    //Steve's lamp bid is : 510
    //Steve's trailer bid is : 700510
    // Maria's trailer bid is : 900460
    //1: A bicycle in so so condition
    // (No bid)
    //2: A brand new lamp
    // (No bid)
    //3: A trailer built in 2001
    // (No bid)
    package stan_bluej_ch4p90;
    import java.util.*;
    //Ex4.14
    * A simple model of an auction.
    * The auction maintains a list of lots of arbitrary length.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.06.08
    public class Auction
    // The list of Lots in this auction.
    private ArrayList lots;
    // The number that will be given to the next lot entered
    // into this auction.
    private int nextLotNumber;
    * Create a new auction.
    public Auction()
         lots = new ArrayList();
         nextLotNumber = 1;
    * Enter a new lot into the auction.
    * Lots can only by entered into the auction by an
    * Auction object.
    * @param description A description of the lot.
    public void enterLot(String description)
         lots.add(new Lot(nextLotNumber, description));
         nextLotNumber++;
    * Show the full list of lot numbers and lot descriptions in
    * this auction. Include any details of the highest bids.
    public void showLots()
         Iterator it = lots.iterator();
         while(it.hasNext()) {
         Lot lot = (Lot) it.next();
         System.out.println(lot.getNumber() + ": " +
                   lot.getDescription());
         // Include any details of a highest bid.
         Bid highestBid = lot.getHighestBid();
         if(highestBid != null) {
              System.out.println(" Highest Bid: " +
                        highestBid.getValue());
         else {
              System.out.println(" (No bid)");
    * Return the lot with the given number. Return null
    * if a lot with this number does not exist.
    * @param number The number of the lot to return.
    public Lot getLot(int number)
         if((number >= 1) && (number < nextLotNumber)) {
         // The number seems to be reasonable.
         Lot selectedLot = (Lot) lots.get(number-1);
         // Include a confidence check to be sure we have the
         // right lot.
         if(selectedLot.getNumber() != number) {
              System.out.println("Internal error: " +
                        "Wrong lot returned. " +
                        "Number: " + number);
         return selectedLot;
         else {
         System.out.println("Lot number: " + number + " does not exist.");
         return null;
    // public void close()
    // Iterator i = lots.iterator();
    // while(i.hasNext())
    //     System.out.println("The winning amount for the " + bicycle.getDescription()
    //     + " is " + bicycle.getHighestBid());
    //     System.out.println("The winning amount for the " + lamp.getDescription()
    //     + " is " + lamp.getHighestBid());
    //     System.out.println("The winning amount for the " + trailer.getDescription()
    //     + " is " + trailer.getHighestBid());
    package stan_bluej_ch4p90;
    * A class that models an auction bid. The bid contains a reference
    * to the Lot bid for and the user making the bid.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.05.31
    public class Bid
    // The user making the bid.
    private final Person bidder;
    // The value of the bid. This could be a large number so
    // the long type has been used.
    private final long value;
    * Create a bid.
    * @param bidder Who is bidding for the lot.
    * @param value The value of the bid.
    public Bid(Person bidder, long value)
         this.bidder = bidder;
         this.value = value;
    * @return The bidder.
    public Person getBidder()
         return bidder;
    * @return The value of the bid.
    public long getValue()
         return value;
    package stan_bluej_ch4p90;
    * A class to model an item (or set of items) in an
    * auction: a lot.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.06.08
    public class Lot
    // A unique identifying number.
    private final int number;
    // A description of the lot.
    private String description;
    // The current highest bid for this lot.
    private Bid highestBid;
    * Construct a Lot, setting its number and description.
    * @param number The lot number.
    * @param description A description of this lot.
    public Lot(int number, String description)
         this.number = number;
         this.description = description;
    * Attempt to bid for this lot. A successful bid
    * must have a value higher than any existing bid.
    * @param bidder Who is bidding.
    * @param value The value of the bid.
    public void bidFor(Person bidder, long value)
         // We trust that lot is genuine. There is nothing to
         // prevent a spurious lot from being bid for, but it
         // would not appear in the auction list.
         if((highestBid == null) ||
         (highestBid.getValue() < value)) {
         // This bid is the best so far.
         setHighestBid(new Bid(bidder, value));
         else {
         System.out.println("\nLot number: " + getNumber() +
                   " (" + getDescription() + ")" +
                   " has a bid of: " +
                   highestBid.getValue());
    * @return The lot's number.
    public int getNumber()
         return number;
    * @return The lot's description.
    public String getDescription()
         return description;
    * @return The highest bid for this lot. This could be null if
    * there are no current bids.
    public Bid getHighestBid()
         return highestBid;
    * @param highestBid The new highest bid.
    private void setHighestBid(Bid highestBid)
         this.highestBid = highestBid;
    package stan_bluej_ch4p90;
    * Maintain details of someone who participates in an auction.
    * @author David J. Barnes and Michael Kolling.
    * @version 2001.05.31
    public class Person
    // The name of this user.
    private final String name;
    * Create a new user with the given name.
    * @param name The user's name.
    public Person(String name)
         this.name = name;
    * @return The user's name.
    public String getName()
         return name;

    Are you ready to kick yourself? The problem lies in the class Auction. You are using showLots() to print the lots, which you are trying to show the lot number, the description and the highest bid. But no there is no where in the class where you set the highest bid. In enterLot() you pass the description of the lot and it creates a new lot with the lot number and the description, but you don't give a bid. Then after the bids are done you do not update Auction to reflect the bids. Let the kicking commence. :-)

  • Workflow for using proxies and AVCHD

    I'm working on a 6 camera mulitcam project of a theatrical performance and I'm using Premiere CC.  The footage is all spanned AVCHD from Canon Vixia's.  My machine is pretty good but no way is it going to play 6 streams of AVCHD at once (I've done 4 and that was pushing it!). 
    I've done a little searching on the forum and found this post:
    http://forums.adobe.com/message/4877276#4877276
    In particular, Fuzzy says:
    The workaround is the following:
    - create a folder for your proxies next to the folder containing original footages and name it e.g. AVCHD.Proxies;
    - transcode your MTS files into MPEG2 ones with the same file names and MTS file extention (or run Batch Rename in Bridge after transcoding with MPG file extention);
    - close your PrPro project, created out of original MTS files;
    - temporarily rename AVCHD folder containing original MTS files to e.g. AVCHD.Sources and AVCHD.Proxies to AVCHD;
    - open up PrPro project and enjoy: all your original AVCHD files are now linked to MPEG2 proxies.
    When you're done, reverse rename folders.
    This idea appeals to me but I've got a question.  My files are all spanned AVCHD.  It seems, in his example, that each .mts has a corresponding mpeg2.  With my spanned clips, how will Premiere know how to put them together properly?  I don't really mind if there is a one frame drop between the mpeg2 clips but will this majorly screw things up when I swap the proxy footage out?
    Is there a better way to do things now, one year on?
    Thanks in advance!

    Hmmmm... still having problems.
    I got back to work this morning (having spent most of the weekend and yesterday raking leaves) to find that all of the mts have successfully been transcoded into mpg clips.  I added a new STREAM folder, moved the clips and changed the file extension to .mts.  So far so good.
    I decided not to stitch the spanned mts clips first because I'm on a Mac and I haven't found a good (free) stitcher.  I have a nice Windows one that I like but i didn't have the time to move the clips to a Windows machine, stitch them and then move them back again.  This may still need to be done because I'm faced with a new problem.
    When I go into Premiere and try to import the mpg clips (now hiding under the .mts extension) I get the error "The file has an unsupported compression type".  This happens if I use the regular import OR the Media Browser.
    Any ideas?  I compressed these in AME using the default "Match Source - Medium Bitrate".  I used the H.264 format, not the MPEG2 format thinking that Macs like H.264 but I wonder if this is the problem
    Thanks for everything, by the way.  You've been more than helpful

  • The type Set is not generic; it cannot be parameterized with arguments K ?

    When I use Hashtable or HashMap to get the keySet, it shows the error of "The type Set is not generic; it cannot be parameterized with arguments <K>".
    The following is my code:
    Hashtable table = new Hashtable();
    table.put("A", new Integer(1));
    table.put("B", new Integer(2));
    Iterator its = table.keySet().iterator(); // <<<<<<<<<<<<<< this line shows the error "The type Set is not generic; it cannot be parameterized with arguments <K>"
    How can I solve it? Please help me! I have no idea on it. It works fine in 1.4.
    Best regards,
    Eric

    The original is my codes, please help!
    public static List findDlicApp(Date startDate, Date endDate, Connection con) {
              String SQL = getSQL("app.sql");
              String where = getSQL("app.sql.where");
              boolean hasWhere = false;
              if (startDate != null) {
                   SQL = SQL + " where d.create_date >= to_date('" + DMSUtil.convertDateToString(startDate) + "', 'yyyy-MM-dd')";
                   hasWhere = true;
              if (endDate != null) {
                   if (hasWhere) {
                        SQL = SQL + " and to_date(to_char(d.create_date, 'yyyy-mm-dd'), 'yyyy-mm-dd') <= to_date('" + DMSUtil.convertDateToString(endDate) + "', 'yyyy-MM-dd')";
                   } else {
                        SQL = SQL + " where to_date(to_char(d.create_date, 'yyyy-mm-dd'), 'yyyy-mm-dd') <= to_date('" + DMSUtil.convertDateToString(endDate) + "', 'yyyy-MM-dd')";
                   hasWhere = true;
              if (hasWhere) {          
                   SQL = SQL + " and " + where;
              } else {
                   SQL = SQL + " where " + where;
              SQL = SQL + " " + getSQL("app.sql.order");
              //System.out.println(SQL);
              //Connection con =  getParaDMConnection("findDlicApp");
              HashMap<String, DlicApp> dlicDocs = new HashMap<String, DlicApp>();
              List result = new ArrayList();
              try {
                   Statement stmt = con.createStatement();
                   ResultSet rs = stmt.executeQuery(SQL);
                   long lastDocID = 0;
                   boolean hasStartDate = false;
                   while(rs.next()) {
                        long docID = rs.getLong("docID");
                        String docName = rs.getString("docName");
                        String refNo = rs.getString("refNo");
                        java.util.Date createDate = rs.getDate("createDate");
                        String creator = rs.getString("creator");
                        String profileType = rs.getString("profileType");
                        String assunto = rs.getString("assunto");
                        String fromEntity = rs.getString("fromEntity");     
                        String location = getLocation(docID, con);
                        long fieldID = rs.getLong("fieldID");
                        String fieldValue = rs.getString("fValue");
                        DlicApp doc = null;
                        if (dlicDocs.containsKey(String.valueOf(docID))) {
                             doc = (DlicApp)dlicDocs.get(String.valueOf(docID));
                        } else {
                             doc = new DlicApp();
                        doc.setId(docID);
                        doc.setDocName(docName);
                        doc.setReferenceNo(refNo);
                        doc.setCreateDate(createDate);
                        doc.setCreator(creator);
                        doc.setProfileType(profileType);
                        doc.setAssunto(assunto);
                        doc.setFrom(fromEntity);
                        //if (doc.getStartDate() == null) {                    
                        //     doc.setStartDate(createDate);
                        doc.setLocation(location);
                        if (fieldValue != null) {                    
                             if (fieldID == 1114) {
                                  doc.setChineseName(fieldValue);
                             if (fieldID == 1115) {
                                  doc.setPortugueseName(fieldValue);
                             if (fieldID == 1116) {
                                  doc.setApplicationCategory(fieldValue);
                             if (fieldID == 1118) {
                                  doc.setStatus(fieldValue);
                             if (fieldID == 1119) {
                                  Date d = DMSUtil.parseDate(fieldValue, "yyyy-MM-dd");
                                  doc.setStartDate(d);
                                  hasStartDate = true;
                             if (fieldID == 1120) {
                                  Date d = DMSUtil.parseDate(fieldValue, "yyyy-MM-dd");
                                  if (!StringUtils.isEmpty(fieldValue)) {
                                       //System.out.println(docName + ":" + fieldValue + ">>>>>>>>>findDlicApp>>>>>>>>>>>>>>>>>>APP END DATE: " + d);
                                       doc.setEndDate(d);
                        if (docID != lastDocID) {                    
                             doc.setRelatedDocs(findRelatedDoc(docID, con));
                             lastDocID = docID;
                        dlicDocs.put(String.valueOf(docID), doc);
                   stmt.close();
                   rs.close();
                   Iterator<String> its = dlicDocs.keySet().iterator();
                   while(its.hasNext()) {
                        String id = (String)its.next();
                        DlicApp a = (DlicApp)dlicDocs.get(id);
                        a.setRelatedDocs(findRelatedDoc(a.getId(), con));
                        dlicDocs.put(id, a);
                   result.addAll(dlicDocs.values());
                   // take out start date is not in the given period
                   int n = 0;
                   while(true) {
                        if (n < result.size()) {
                             DlicApp a = (DlicApp)result.get(n);               
                             Date sd = a.getStartDate();
                             if (!isWithin(sd, startDate, endDate)) {
                                  result.remove(n);
                             } else {
                                  n++;
                        } else {
                             break;
              } catch(Exception e) {
                   e.printStackTrace();
              if (result.size() > 0) {
                   Collections.sort(result, new DmsDocComparator());
              return result;
         }Edited by: EJP on 13/01/2011 14:41: added code tags for you. Please use them next time.

  • Not saving data after we raise an exception

    Hi,
    I extended continue button function in OTL - Timecard. If we throw any error in continue button, then after do the required modifications to the data and click on Save button , for the first time the save is not working. Then again click on save, the data is getting to the database.
    Any suggestions would be greatly appreciated.
    Thanks in advance
    Kalyani

    Hi,
    Please find the code in save
    if(sA != null && sA != "" && sA.equals("TimecardSaveForLater"))
    oapagecontext.writeDiagnostics(this,"am in save >>>>>>",6);
    oadbtransaction.putValue("CheckSave", "Y");
    long l = GlobalUtilities.getLongOrNullFromObject(oapagecontext.getParameter("TimecardId"));
    oapagecontext.writeDiagnostics(this,"am in save >>> timecard id.."+l,6);
    if(-1L == l)
    l = GlobalUtilities.getLongOrNullFromObject(oapagecontext.getParameter("Timecard_id"));
    oapagecontext.writeDiagnostics(this,"am in save >>>> timecard id.."+l,6);
    ValidationforZeroRowsVOImpl zeroVO = (ValidationforZeroRowsVOImpl)oaapplicationmodule.findViewObject("ValidationforZeroRowsVO");
    oapagecontext.writeDiagnostics(this,"second vo on click continue button.."+zeroVO,6);
    if(zeroVO == null)
    zeroVO = (ValidationforZeroRowsVOImpl)oaapplicationmodule.createViewObject("ValidationforZeroRowsVO", "sonata.oracle.apps.hxc.selfservice.timecard.server.ValidationforZeroRowsVO");
    zeroVO.setWhereClause(null);
    zeroVO.setWhereClauseParam(0,l);
    zeroVO.executeQuery();
    oapagecontext.writeDiagnostics(this,"second vo row count on click continue button.."+zeroVO.getRowCount(),6);
    }else
    zeroVO.setWhereClause(null);
    zeroVO.setWhereClauseParam(0,l);
    zeroVO.executeQuery();
    oapagecontext.writeDiagnostics(this,"second vo row count on click continue button with else.."+zeroVO.getRowCount(),6);
    oapagecontext.writeDiagnostics(this,"second vo row count on click continue button with else.."+zeroVO.getQuery(),6);
    ValidationforZeroRowsVORowImpl Zerorow = null;
    int fetchedRowCount = zeroVO.getFetchedRowCount();
    oapagecontext.writeDiagnostics(this,"fetchedRowCount>>>>fetchedRowCount.."+fetchedRowCount,6);
    RowSetIterator zeroIter = zeroVO.createRowSetIterator("zeroIter");
    String chkVal = "Delete";
    if(fetchedRowCount > 0)
    zeroIter.setRangeStart(0);
    zeroIter.setRangeSize(fetchedRowCount);
    for (int i = 0; i < fetchedRowCount; i++)
    oapagecontext.writeDiagnostics(this,"am in for loop ..",6);
    Zerorow = (ValidationforZeroRowsVORowImpl)zeroIter.getRowAtRangeIndex(i);
    if(Zerorow.getMeasure() != null)
    oracle.jbo.domain.Number primaryKey = Zerorow.getMeasure();
    oapagecontext.writeDiagnostics(this,"primaryKey>>>>primaryKey.."+primaryKey,6);
    oracle.jbo.domain.Number timeBuildingID = Zerorow.getTimeBuildingBlockId();
    oapagecontext.writeDiagnostics(this,"timeBuildingID>>>>timeBuildingID.."+timeBuildingID,6);
    int zero = 0;
    Number y = 0;
    String timcardID = Zerorow.getTimeBuildingBlockId().toString();
    oapagecontext.writeDiagnostics(this,"am in for loop with time card build id.."+timeBuildingID,6);
    if(primaryKey.compareTo(zero) == 0)
    oapagecontext.writeDiagnostics(this,"am in primarykey validation true..",6);
    OADBTransaction dbtrans = oaapplicationmodule.getOADBTransaction();
    String procedureStr = "BEGIN son_delete_zero_time(:1); END;";
    OracleCallableStatement callablestatement = (OracleCallableStatement)dbtrans.createCallableStatement(procedureStr, 1);
    try{
    oapagecontext.writeDiagnostics(this,"AM in delte before close..",6);
    callablestatement.setInt(1, Integer.parseInt(timcardID));
    callablestatement.execute();
    callablestatement.close();
    oapagecontext.writeDiagnostics(this,"AM in delte after close..",6);
    chkVal = "AfterDel";
    }catch(SQLException _sqle) {  try
    callablestatement.close();
    catch(Exception e) { }
    throw OAException.wrapperException(_sqle);}
    }oapagecontext.writeDiagnostics(this,"am in primarykey validation false..",6);
    }oapagecontext.writeDiagnostics(this," am in close iterator",6);
    //break; // only one possible selected row in this case
    }zeroIter.closeRowSetIterator();
    }

  • Two NIO questions

    Hi,
    I'm very intrigued by some of the possible performance enchancements my application can use with NIO. I've got 2 situations that I want to ask the NIO experts about:
    1. In one scenario, I do my own "broadcasts" over TCP (instead of UDP) by populating an OutputStream that is backed by a ByteArrayOutputStream. Then I convert my ByteArrayOutputSTream to a byte[] using toByteArray, and for each one of my OutputStream's I need to broadcast to (these are OutputStreams going thru Sockets), I write the entire byte[] into it. Is there a more efficient way to handle this with NIO? It seems like there is lots of extra bytes being copied in the JVM since the same byte[] is being sent to multiple OutputStreams. Would using a direct ByteBuffer help? Is there a performance penalty for using a ByteBuffer instead of a byte[] if I'm only sending it to one OutputStream?
    2. In another scenario, I'm reading an InputStream. After a certain point of reading the stream, I need to redirect the remaining bytes in the stream to an OutputStream. Currently I'm populating the remaining bytes of the InputStream into a ByteArrayOutputStream, convert it to a byte[] usinng toByteArray(), and then send that out to my designated OutputStream. Once again, it seems like I'm doing unnecessary copying of bytes and the NIO package should have something to directly transfer the bytes from my InputStream to my OutputStream.
    Thank you in advance for any help.
    Mark

    Well here is some pseudo-code for my first scenario.. It's basically restating what I explained earlier but I hope this helps:
    import java.io.*;
    public class Asdf{
    private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    public ObjectOutputStream getOutputStream(){
         this.byteArrayOutputStream.reset();
         return new ObjectOutputStream(this.byteArrayOutputStream);
    public void broadcastMessage(ObjectOutputStream oos){
         oos.close();
         Iterator broadcastOutputStreamIter = getBroadcastOutputStreamIter();
         while (broadcastOutputStreamIter.hasNext()){
         ObjectOutputStream curOos = (ObjectOutputStream)broadcastOutputStreamIter.next();
         this.byteArrayOutputStream.writeTo(curOos);
         curOos.flush();
    private Iterator getBroadcastOutputStreamIter(){
         //left out for clarity
    public static void main(String[] args){
         Asdf asdf = new Asdf();
         ObjectOutputStream oos = asdf.getOutputStream();
         oos.writeObject("asdflkj");
         oos.writeBoolean(true);
         broadcastMessage();
    To use NIO, I assume instead of using a ByteArrayOutputStream, I need to use a ByteBuffer, right? How would I tie in my usage of my ObjectOutputStream with the ByteBuffer? Or would I have to just create a new ByteBuffer on my ByteArrayOutputStream within broadcastMessage() and send that out over my Socket's Channel?
    I actually haven't written code for #2 yet b/c I'm trying to figure this out. Basically I want to create an ObjectInputStream from a socket, and after reading an undetermined number of objects from the stream, I want to send the remaining bytes of that stream to another Socket's OutputStream.
    Thanks,
    Mark

  • Visa Open and Close on every iteration of loop

    I have noticed that when you open the front panel of the Instrument I/O Assistant, the diagram starts with a visa session open, sets timeout property, writes, reads, parses data and ends with a visa session closed.  If I were to place this into a while loop the visa session would open and close on each iteration of the loop. 
    Is it common practice to open and close the visa session on each iteration?

    No you would not want to open and close that often. If you want to use the Instrument I/O assistant what I would do is configure it the way you want and then save it under another name so you can open the block diagram. Pull the VISA open and close outside of your loop.
    Using LabVIEW 2010SP1 and TestStand 4.5

Maybe you are looking for

  • Stuttering Transition on encode

    Hey Guys - Working on a DVD project for a client. The feature portion of the project is a 55 min clip that was edited in iMovie. I don't have the iMovie project I have a DV export of the video. I encoded the DV file in Compressor to m2v and ac3 audio

  • Oracle Driver Issue in Glassfish

    Hi Everyone, I have a setup where an application is deployed in Glassfish and connecting to Oracle Database. ojdbc14.jar is being used for connecting from Glassfish to Oracle DB. We are using connection pooling here and i even enabled Validation thro

  • Where are saved the user preferences for SCANNER DR-7080C?

    SCANNER CANON DR-7080C Please help me  !!! I was told to replicate the scanner user preferences in several PCs (15), and several users (20 in each PC). This is a image that show several user preferences i prepared for one user. AUT-CAR-1C-COL AUT-CAR

  • SRW224G4 - Can't change port to PVE groupings

    I have a Linksys SRW224G4. Two PVE groups are in use. However I can't change which PVE group a port is assigned to. The option to change the group is there but ghosted out and can't be selected. I downloaded the user manual but it describes a web int

  • 3rd party repository+damage [SOLVED]

    Hey friend. I have seen the following complaints online when search for it but none of the threads helped me solved my forum. I've done some damage to my system. There are many programs I can't start. The error message that I get is /usr/lib/chromium