Override argument in compareTo()

Hi,
When we override equals() method , you must take an argument of type "Object" but when we need to override compareTo() we should take an argument of the type you are searching. why not we pass "Object" type argument in compareTo() ??
for example , if we want to sort of type Person class which implement comparable interface , we use signature like compareTo(Person personObject) not compareTo(Object) ... why ??
Thanks in Advance ,
Rishi

(admittedly, Object<T extends Object> would be a confusing definition for the top superclass which Java newbie generally discover on day 1).Wouldn't it just be Object<T>?Yes, sorry.
It is a pity that equals() can't be generified. Maybe it's time for Java to consider an Equivalent<T> interface and retro-fit it to the collections framework (which is, after all where we use it most); but maybe it's too late now.Probably too late. The operative method of this interface couldn't be named equals (with what I understand of generics' erasure, this would conflict with all existing code where an equals(Object) already exists). Even if it were possible to solve the inconsistency with a special-purpose JLS rule, which I doubt, there would be an ambiguity in existing code that calls equals(Object) .
Assuming the method would have a different name, again upward compatibility would prevent the existing Collection classes from disregarding equals(Object), so the JDK team would need to duplicate all collection classes, one version in terms of equals(Object), the other version in terms of the new method. I don't think that would simplify things overall...

Similar Messages

  • Cannot override "codebase" with javaws -codebase argument with java 1.7.0_40

    I have a jnlp application. The online installation is working perfectly.
    But when I try to install it from cd or hard disc, it is not working. The -codebase parameter will be ignored.
    I am offline and java always tries to download the source files from the "codebase" of the .jnlp file ignoring the override parameter.
    When I try the "javaws -codebase file:///c://test -import c:\test\test.jnlp" I get an error "application cannot be installed" and a detailed information "unable to download the application from location http:...".
    I am using the java 1.7.0_40 32 bit version.
    None of the described solutions in the following links are working:
    https://today.java.net/pub/a/today/2008/07/10/distributing-web-start-via-cd-rom.html
    How to use the Java Web Start CD-Install feature ?
    i have searched the web but I couldnt find a solution or a confirmation that this is a bug. I searched the bug data bank too, but I couldnt find anything.
    Any help will be much appreciated. Actually I just want to do a very simple thing.
    If I am online while performing the import with the -codebase override argument then java download the application from the original .jnlp "codebase" web adress.
    HINT: With a windows 64 bit and java 64 bit the import works offline and the override works too.

    Have you examined the jnlp download servlet implementation? Whenever I have issues like this, I connect my eclipse to the server and step through the jnlp download servlet code to see what is going on. Usually its my mistake.

  • ...is not abstract and does not override abstract method compare

    Why am I getting the above compile error when I am very clearly overriding abstract method compare (ditto abstract method compareTo)? Here is my code -- which was presented 1.5 code and I'm trying to retrofit to 1.4 -- followed by the complete compile time error. Thanks in advance for your help (even though I'm sure this is an easy question for you experts):
    import java.util.*;
       This program sorts a set of item by comparing
       their descriptions.
    public class TreeSetTest
       public static void main(String[] args)
          SortedSet parts = new TreeSet();
          parts.add(new Item("Toaster", 1234));
          parts.add(new Item("Widget", 4562));
          parts.add(new Item("Modem", 9912));
          System.out.println(parts);
          SortedSet sortByDescription = new TreeSet(new
             Comparator()
                public int compare(Item a, Item b)   // LINE CAUSING THE ERROR
                   String descrA = a.getDescription();
                   String descrB = b.getDescription();
                   return descrA.compareTo(descrB);
          sortByDescription.addAll(parts);
          System.out.println(sortByDescription);
       An item with a description and a part number.
    class Item implements Comparable     
          Constructs an item.
          @param aDescription the item's description
          @param aPartNumber the item's part number
       public Item(String aDescription, int aPartNumber)
          description = aDescription;
          partNumber = aPartNumber;
          Gets the description of this item.
          @return the description
       public String getDescription()
          return description;
       public String toString()
          return "[descripion=" + description
             + ", partNumber=" + partNumber + "]";
       public boolean equals(Object otherObject)
          if (this == otherObject) return true;
          if (otherObject == null) return false;
          if (getClass() != otherObject.getClass()) return false;
          Item other = (Item) otherObject;
          return description.equals(other.description)
             && partNumber == other.partNumber;
       public int hashCode()
          return 13 * description.hashCode() + 17 * partNumber;
       public int compareTo(Item other)   // OTHER LINE CAUSING THE ERROR
          return partNumber - other.partNumber;
       private String description;
       private int partNumber;
    }Compiler error:
    TreeSetTest.java:25: <anonymous TreeSetTest$1> is not abstract and does not over
    ride abstract method compare(java.lang.Object,java.lang.Object) in java.util.Com
    parator
                public int compare(Item a, Item b)
                           ^
    TreeSetTest.java:41: Item is not abstract and does not override abstract method
    compareTo(java.lang.Object) in java.lang.Comparable
    class Item implements Comparable
    ^
    2 errors

    According to the book I'm reading, if you merely take
    out the generic from the code, it should compile and
    run in v1.4 (assuming, of course, that the class
    exists in 1.4). I don't know what book you are reading but that's certainly incorrect or incomplete at least. I've manually retrofitted code to 1.4, and you'll be inserting casts as well as replacing type references with Object (or the erased type, to be more precise).
    These interfaces do exist in 1.4, and
    without the generics.Exactly. Which means compareTo takes an Object, and you should change your overriding method accordingly.
    But this raises a new question: how does my 1.4
    compiler know anything about generics? It doesn't and it can't. As the compiler is telling you, those interfaces expect Object. Think about it, you want to implement one interface which declares a method argument type of Object, in several classes, each with a different type. Obviously all of those are not valid overrides.

  • Object CompareTo

    Hi all, I have this linked list class which needs to insert nodes of different objects (eg Person, Company, Invoice) in ascending order.
    I get this error:
    List is not abstract and does not override abstract method compareTo(java.lang.Object) in java.lang.Comparable
    however I have declared compareTo at the 3 different classes in Person, Company and Invoice. What should I do to make my List class generic so that I am able to use the compareTo inside List insert() to call the appropriate class instead?? Thanks in advance
    import java.lang.Comparable;
    class List implements Comparable
        public void insert(Object var)
            ListNode newNode = new ListNode(var);
            setNumItems(size()+1);
            if(isEmpty())
                setHead(newNode);
            else
            {   ListNode prev=null;
                for(ListNode curr=getHead(); curr != null; prev = curr, curr=curr.getNext())
                    Object tmpItem = curr.getItem();
                    if(tmpItem.compareTo(var) > 0)
                        // insert before curr node
                        newNode.setNext (curr);
                        if (prev != null)
                            prev.setNext (newNode);
                        else
                            setHead (newNode);
                        return;
                // insert at end of list
                prev.setNext (newNode);
        }

    hi tijacobs01,
    here's my Customer class
    public abstract class Customer implements Comparable
        public int compareTo(Object o)
            // A positive result means this AcountID is bigger
            // A zero result means that both AccountID are the same
            // A negative result means  this AccountID is smaller
            return getAccountID() - ((Customer)o).getAccountID();
    }so I should amend to this?
    public void insert(Comparable var)
            ListNode newNode = new ListNode(var);
            setNumItems(size()+1);
            if(isEmpty())
                setHead(newNode);
            else
            {   ListNode prev=null;
                for(ListNode curr=getHead(); curr != null; prev = curr, curr=curr.getNext())
                    Object tmpItem = curr.getItem();
                    if(var.compareTo(tmpItem) > 0)
                        // insert before curr node
                        newNode.setNext (curr);
                        if (prev != null)
                            prev.setNext (newNode);
                        else
                            setHead (newNode);
                        return;
                // insert at end of list
                prev.setNext (newNode);
        }

  • Implementing the CompareTo(Object T) method of interface Comparable T

    Hi,
    I cannot figure out how to write implementation to compare two objects for the CompareTo method.
    I have an Employee class and a Manager class that inherits Employee and in the main method i want to sort the objects so that i can use the method binarySearch(Object[] a, Object key), originally i sorted each object in order of their salaries but i now need to be able to distinguish between a Manager object and an Employee object.

    demo:
    class Base implements Comparable<Base> {
        private String baseField;
        @Override public int compareTo(Base that) {
            return this.baseField.compareTo(that.baseField);
    class Derived extends Base {
        private String derivedField;
        @Override public int compareTo(Base that) {
            int result = super.compareTo(that);
            if (result == 0 && that instanceof Derived) {
                Derived thatThang = (Derived) that;
                result = this.derivedField.compareTo(thatThang.derivedField);
            return result;
    }Base objects are ordered by baseField. (I assume all fields will be non-null, for simplicity.) Between Derived objects with equal baseField, I order them further by derivedField.
    edit. I should mention that there are headaches that usually follow when you compare objects of different types. Suppose you have three objects:
    obj1, a Derived object with baseField = "b", derivedField = "x"
    obj2, a Base object with baseField = "b"
    obj3, a Derived object with baseField = "b", derivedField = "y"
    according to the compareTo methods, obj1 and obj2 are equal, and as well, obj2 and obj3 are equal, but obj1 and obj3 are not equal, so we do not have transitivity. ;-(

  • Cannot compile java Programs

    hi everyone,
    when i tried to compile a java Program i had created.I got the following Error.
    Error occoured during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
    I reinstalled the entire thing from the system and when i tried to compile the java Program again it gives like a 1000 errors even on the programs i know that work fine and even the very basic 5 or 10 line Programs.Can someone tell me what is happening??

    Having Deleted a file in the folder that i was executing the javac seem to have fixed the problem.It was called String.java
    and the content of the file were as mentioned under:Any help on why it happened or what the file was doing would be really appreciated.
    The content of the file:-
    ""Java String Examples
    The String class implements immutable character strings, which are read-only once the string object has been created and initialized. All string literals in Java programs, are implemented as instances of String class.
    The easiest way to create a Java String object is using a string literal:
    1.
    String str1 = "I can't be changed once created!";
    A Java string literal is a reference to a String object. Since a String literal is a reference, it can be manipulated like any other String reference. i.e. it can be used to invoke methods of String class.
    For example,
    1.
    int myLenght = "Hello world".length();
    The Java language provides special support for the string concatenation operator (+), which has been overloaded for Java Strings objects. String concatenation is implemented through the StringBuffer class and its append method.
    For example,
    1.
    String finalString = "Hello" + "World";
    Would be executed as
    1.
    String finalString = new StringBuffer().append("Hello").append("World").toString();
    The Java compiler optimizes handling of string literals. Only one String object is shared by all strings having same character sequence. Such strings are said to be interned, meaning that they share a unique String object. The Java String class maintains a private pool where such strings are interned.
    For example,
    1.
    String str1="Hello";
    2.
    String str2="Hello";
    3.
    If(str1 == str2)
    4.
    System.out.println("Equal");
    Would print Equal when executed.
    Since the Java String objects are immutable, any operation performed on one String reference will never have any effect on other references denoting the same object.
    String Constructors
    String class provides various types of constructors to create String objects. Some of them are,
    String()
    Creates a new String object whose content is empty i.e. "".
    String(String s)
    Creates a new String object whose content is same as the String object passed as an argument.
    Note: Invoking String constructor creates a new string object, means it does not intern the String. Interned String object reference can be obtained by using intern() method of the String class.
    String also provides constructors that take byte and char array as an argument and returns String object.
    String equality - Compare Java String
    String class overrides the equals() method of the Object class. It compares the content of the two string object and returns the boolean value accordingly.
    For example,
    1.
    String str1="Hello";
    2.
    String str2="Hello";
    3.
    String str3=new String("Hello") //Using constructor.
    4.
    5.
    If(str1 == str2)
    6.
    System.out.println("Equal 1");
    7.
    Else
    8.
    System.out.println("Not Equal 1");
    9.
    10.
    If(str1 == str3)
    11.
    System.out.println("Equal 2");
    12.
    Else
    13.
    System.out.println("I am constructed using constructor, hence not interned");
    14.
    15.
    If( str1.equals(str3) )
    16.
    System.out.println("Equal 3");
    17.
    Else
    18.
    System.out.println("Not Equal 3");
    The output would be,
    Equal 1
    Not Equal 2
    Equal 3
    Note that == compares the references not the actual contents of the String object; Where as equals method compares actual contents of two String objects.
    String class also provides another method equalsIgnoreCase() which ignores the case of contents while comparing.
    Apart from these methods String class also provides compareTo methods.
    int compareTo(String str2)
    This method compares two Strings and returns an int value. It returns
    - value 0, if this string is equal to the string argument
    - a value less than 0, if this string is less than the string argument
    - a value greater than 0, if this string is greater than the string argument
    int compareTo(Object object)
    This method behaves exactly like the first method if the argument object is actually a String object; otherwise, it throws a ClassCastException."""
    Edited by: Gold_y on Oct 30, 2009 4:59 AM

  • Comparator non returning 0

    I'm implementing a model in which it is impossible to be two equal items. They're ordered exclusively by an unique index.
    I have to implement comparator. Is it OK to implment it like the following? Is it very bad not to put the 0? Does it make any sense at all to put the 0 option? Thanks
    @Override
         public int compareTo(MyClass o) {
              if (index > o.getIndex()) {
                   return 1;
              return index == o.getIndex() ? 0 : -1;
         }What about not putting it. Would it be bad?

    ldepablo wrote:
    I'm implementing a model in which it is impossible to be two equal items. They're ordered exclusively by an unique index.
    I have to implement comparator. Is it OK to implment it like the following? Is it very bad not to put the 0? Does it make any sense at all to put the 0 option? ThanksThe definition of the type says two items can never have the same index. It seems to me it's not this comparator's job to enforce that. It's job is merely to order already existing items by their index, so returning zero if they're equal is fine. That code will never be executed, but that's okay. Later, if you change the rules for some reason--like maybe a before and after version of a particular item can exist briefly in a limited context--then the comparator doesn't have to change. Validating the indices is not part of the comparator's responsibility.
    What you might want is something to verify that you're not reusing an existing index, and throw an unchecked exception if it is (such as IllegalArgumentException, IllegalStateException, or your own class that extends RuntimeExcception). However, if the indices are generated in your code and are private and final within one of these items, then that may not be necessary, if you can be confident that they're unique.
    Then of course there's the possibility of the same object being referred to by both arguments to the compare() method. Obviously, you need to return zero then.

  • Array creation in generic method.

    I have next class.
    public class Data implements Comparable<Data>
        private int val;
        public Data(int val)
            this.val = val;
        public int getVal()
            return val;
       public void setVal(int val)
            this.val = val;
        @Override
        public int compareTo(Data o)
            return val - o.val;
    And I need create a duplicated array of Data object in a method which is a template with variable type
    public class CopyClass
        public static int[] duplicate ( int[] data)
            int array[] = new int [data.length * 2];
            for (int i = 0; i < data.length; i++)
                array[2*i] = data[i];
                array[2*i+1] = data[i];
            return array;
        public static<T extends Comparable<? super T>> T[] duplicate ( T[] data)
            T array[] = (T[])new Object [data.length * 2];
            for (int i = 0; i < data.length; i++)
                array[2*i] = data[i];
                array[2*i+1] = data[i];
            return array;
        public static void logg ( int[] data)
            String msg = "{";
            for (int d : data)
                msg += " " + d;
            msg += "}";
            System.out.println(msg);
        public static void main (String []args)
            int [] val = { 7, 14, 2};
            int [] vals = duplicate(val);
            logg(val);
            logg(vals);
            Data[] data = {new Data(7), new Data(14), new Data(2)};
            Data[] datas = duplicate(data);
    Firts duplicate method works fine because it has a integer array as parameter an return an array whom values are duplicated.
    Second duplicate methos don't works.
    { 7 14 2}
    { 7 7 14 14 2 2}
    Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Comparable;
      at analisis.utilidades.CopyClass.duplicate(CopyClass.java:30)
      at analisis.utilidades.CopyClass.main(CopyClass.java:60)
    Java Result: 1
    Who I can create this kind of objects arrays?

    T array[] = (T[])Array.newInstance(data.getClass().getComponentType(), data.length * 2);

  • Exception is being thrown

    I tried out this small code for using hashset but it gives exceptions. I have no idea why is it so?
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    class Students implements Comparable
         private String name;
         private float gpa = 0.0F;
         Students(String n, float g)
              name = n;
              gpa = g;
         Students(){}
         public String getName() {
              return name;
         public float getGpa() {
              return gpa;
         @Override
         public int compareTo(Object o) {
              // TODO Auto-generated method stub
              if(this.getGpa() > ((Students)o).getGpa())
                   return 1;
              else if(this.getGpa() < ((Students)o).getGpa())
                   return -1;
              else
                   return 0;
         public boolean equals(Object o){
              if(this.getGpa() == ((Students)o).getGpa())
                   return true;
              else
                   return false;
         public int hashCode(){
              return (int)(10*gpa);
    public class HashFunction {
         public static void main(String args[]){
              Students s1= new Students("Fred", 3.0F);
              Students s2 = new Students("Sam", 3.1F);
              Students s3 = new Students("Steve", 3.5F);
              Set s = new HashSet();
              s.add(s1);
              s.add(s2);
              s.add(s3);
              Iterator i = s.iterator();
              while(i.hasNext())
                   System.out.println(((Students)i.next()).getName() + " " + ((Students)i.next()).getGpa());
    }The exception trace that is generated is as follows:
    Exception in thread "main" java.util.NoSuchElementException
         at java.util.HashMap$HashIterator.nextEntry(HashMap.java:796)
         at java.util.HashMap$KeyIterator.next(HashMap.java:828)
         at HashFunction.main(HashFunction.java:68)

    roaan wrote:
    I had one more question. I am reading from the file like this
              String word;
              word = file.nextWord();
              try{
                   while(word != null)
                        word = word.toLowerCase();
                        wf.put(word);
                        word = file.nextWord();
              catch(Exception e){
                   e.printStackTrace();
         }Now when the end of the file is reached word contains null and throws a nullpointer exception. I am catching that exception but is there a way out that when my word is null i should simply exit out of the loop (i check that word is not equal to null in my while loop but still it throws an excpetion).Nothing there can throw NPE from word being null. The only possibilities of NPE in the code you posted are
    1. if file is null
    2. if wf is null
    3. if NPE is being thrown inside nextWord(), which has nothing to do with word being null.
    Once you make sure that the above are not happening, that code will be fine and you won't need to catch NPE. And in fact, catching NPE like that is bad practice anyway.

  • How can I sort a collection of array with different object types in it ?

    Hi all,
    I have a collection of ArrayList; each array contains, at the first position, the same object type.
    I'd like sorting the collection by the name contained in the object at the first position of each array.
    Any suggestion ?
    Cheers.
    Stefano

    so you have a collection of a collection?
    My guess is that:
    You could subclass the arraylist and override it's compareTo method (I think that it implements comparable already but if not, go ahead and implement that interface).
    Or you could wrap your arraylist in another class that implements comparable.
    The key in my mind is correctly coding your compareTo method to look at the name in the first item of the arraylists. This should be doable and not too difficult.
    Correction: after reviewing the ArrayList api, I see that it doesn't implement the Comparable interface. You will have to make any class that either inherits arraylist or contains arraylist implement the comparable interface.
    One last thing: This question would probably have been better off in the java forum and not the Swing forum since it doesn't really involve Swing.
    Good luck!
    Edited by: petes1234 on Nov 19, 2007 6:17 AM

  • 3.6 Group Aggregation Question

    I am trying to achieve a sql group by sort of behavior with coherence 3.6. I have achieved some success by using the following code.
    public InvocableMap.EntryAggregator getAggregationCriteria()
    BigDecimalSum agg1 = new BigDecimalSum("getTradeDateMVLocal");
    BigDecimalSum agg2 = new BigDecimalSum("getTradeDateCashLocal");
    BigDecimalSum agg3 = new BigDecimalSum("getCostLocal");
    BigDecimalSum agg4 = new BigDecimalSum("getInterestUnrealizedLocal");
    CompositeAggregator compAgg =
    CompositeAggregator.createInstance(new InvocableMap.EntryAggregator[]
    {agg1, agg2, agg3, agg4});
    ChainedExtractor cr1 = new ChainedExtractor("getKey.getAccountName");
    ChainedExtractor cr2 = new ChainedExtractor("getKey.getCurrency");
    ValueExtractor[] extractors = new ValueExtractor[2];
    extractors[0] = cr1;
    extractors[1] = cr2;
    MultiExtractor multiEx = new MultiExtractor(extractors);
    GroupAggregator gpa = GroupAggregator.createInstance(multiEx, compAgg);
    return gpa;
    once the GroupAggregator is constructed I pass it to the namedcache.aggregate method using the following wrapper method.
    public LiteMap aggregate(NamedCache cache, Filter filter, InvocableMap.EntryAggregator aggregationCriteria)
    LiteMap map = (LiteMap) cache.aggregate(filter, aggregationCriteria);
    return map;
    the issue is that in a multi-node environment not all the data is aggregated.
    for example if i have a single node and i run my aggregation code just in that node i get the expected number of grouped items. in a multi node scenario it ends up with lesser items. now the columns that i am grouping by are part of my composite key for the cache. the implementation of my key class is as follows.
    package com.sac.dream.model;
    import com.sac.dream.core.model.GridEntityKey;
    import com.sac.dream.util.externalization.ObjectReader;
    import com.sac.dream.util.externalization.ObjectWriter;
    import com.tangosol.net.cache.KeyAssociation;
    import javax.persistence.Embeddable;
    import javax.persistence.Transient;
    import java.io.IOException;
    * Created by IntelliJ IDEA.
    * User: ahmads
    * Date: Jul 28, 2010
    * Time: 1:54:45 PM
    * To change this template use File | Settings | File Templates.
    @Embeddable
    public class GenevaValuationKey extends GridEntityKey implements KeyAssociation
    private static final long serialVersionUID = 1L;
    private String accountName;
    private String currency;
    private Long uid;
    public GenevaValuationKey(Long uid)
    this.uid = uid;
    public GenevaValuationKey()
    @Transient
    public Object getAssociatedKey()
    int hash = 1;
    hash = hash * 31 + getAccountName().hashCode();
    hash = hash * 31 + getCurrency().hashCode();
    return hash;
    public void setAssociatedKey(Object value)
    public Long getUid() {
    return uid;
    public void setUid(Long uid) {
    this.uid = uid;
    @Override
    public String toString()
    return "GenevaValuationKey::uid:" + this.uid;
    @Override
    public boolean equals(Object o)
    //if(this == o) return true;
    //if (o == null || getClass() != o.getClass()) return false;
    GenevaValuationKey that = (GenevaValuationKey) o;
    if(this.getAccountName().equals(that.getAccountName()) && this.getCurrency().equals(that.getCurrency()) && this.uid == that.uid)
    return true;
    else
    return false;
    @Override
    public int hashCode()
    int hash = 1;
    hash = hash * 31 + getAccountName().hashCode();
    hash = hash * 31 + getCurrency().hashCode();
    hash = hash * 31 + uid.hashCode();
    return hash;
    @Override
         public int compareTo(GridEntityKey o)
    return this.uid.compareTo(((GenevaValuationKey) o).getUid());
    @Override
    public final void readObject(ObjectReader reader) throws IOException
    try
    this.setAccountName(reader.readString());
    this.setCurrency(reader.readString());
         this.uid = reader.readLong();
    catch(IOException e)
    throw new RuntimeException(e);
    @Override
         public final void writeObject(ObjectWriter writer) throws IOException
    try
    writer.writeString(this.getAccountName());
    writer.writeString(this.getCurrency());
         writer.writeLong(this.uid);
    catch(IOException e)
    throw new RuntimeException(e);
    public String getAccountName() {
    return accountName;
    public void setAccountName(String accountName) {
    this.accountName = accountName;
    public String getCurrency() {
    return currency;
    public void setCurrency(String currency) {
    this.currency = currency;
    i implemented the keyassociation assuming that i need to make sure that for a certain group all the rows within that group need to exist on the same node. there might be something wrong with that implementation.
    thanks

    rehevkor5 wrote:
    Yeah apparently you're not supposed to call readRemainder or writeRemainder from within the PortableObject methods, too bad the documentation does not mention this.
    Here is a better idea of what a subclass's PortableObject methods should look like:
    @Override
    public void readExternal(PofReader in) throws IOException {
    super.readExternal(in.createNestedPofReader(0));
    myObj = (MyType) in.readObject(1);
    @Override
    public void writeExternal(PofWriter out) throws IOException {
    super.writeExternal(out.createNestedPofWriter(0));
    out.writeObject(1, myObj);
    }Since you cannot read or write the remainder, the way that you support PortableObjects that need to evolve is by implementing the Evolvable interface. Coherence will detect that your object is an instanceof Evolvable, and will handle reading/writing the remainder/futureData and dataVersion for you.Yep. Otherwise, if you have handled the remainder in a PortableObject, you would not be able to sensibly override that method which handled the remainder.
    Best regards,
    Robert

  • Lazying question

    Hi.
    I am not sure what is going on, so here we go :)
    I have a "lazy" ManyToOne relationship :
    @Entity
    public class Build implements Serializable, Comparable<Build> {
    @ManyToOne (fetch=FetchType.LAZY)
    @JoinColumn(name="MYSWRELEASE_RELEASEID")
    protected SWRelease mySWRelease;
    public void setSWRelease (SWRelease in) {
    this.mySWRelease=in;
    public SWRelease getSWRelease() {
    return mySWRelease;
    @Entity
    public class SWRelease implements Serializable, Comparable<SWRelease> {
    @OneToMany(cascade=CascadeType.ALL, mappedBy="mySWRelease", fetch=FetchType.LAZY)
    private Set<Build> myBuilds = new TreeSet<Build>();
    public void setBuilds (Set<Build> in) {
    this.myBuilds=in;
    public Set<Build> getBuilds() {
    return myBuilds;
    When I try to get the builds from SWRelease , I get {IndirectSet: not instantiated},
    here is the test code:
    SWRelease sr=em.find(SWRelease .class,1);
    System.out.println("release builds: "+sr.getBuilds());
    prints:
    release builds: {IndirectSet: not instantiated}
    but I can get the SWRelease from the build:
    Build b=em.find(Build.class,1);
    System.out.println("release : "+b.getSWRelease());
    prints:
    release : Release 1
    Why I am getting {IndirectSet: not instantiated} ?
    Here is the code + persitance.xml
    import java.io.Serializable;
    import java.util.*;
    import javax.persistence.*;
    @Entity
    public class Build implements Serializable, Comparable<Build> {
    private static final int HASH_PRIME=37;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    private Integer buildId;
    @ManyToOne (fetch=FetchType.LAZY)
    @JoinColumn(name="MYSWRELEASE_RELEASEID")
    protected SWRelease mySWRelease;
    @Column(name="number")
    private String number;
    @Column(name="date")
    @Temporal(TemporalType.DATE)
    private Date date;
    public Build() {
    super();
    public Date getDate() {
    return date;
    public void setDate(Date in) {
    this.date=in;
    public String getNumber() {
    return number;
    public void setNumber(String in) {
    this.number=in;
    public void setBuildId(Integer in) {
    this.buildId = in;
    public Integer getBuildId() {
    return this.buildId ;
    public void setSWRelease (SWRelease in) {
    this.mySWRelease=in;
    public SWRelease getSWRelease() {
    return mySWRelease;
    //@Override
    public int hashCode() { 
    int ret=0;
    ret = HASH_PRIME * (ret + (date !=null ? date.hashCode() : 0));
    ret = HASH_PRIME * (ret + (number !=null ? number.hashCode() : 0));
    ret = HASH_PRIME * (ret + (buildId !=null ? buildId .hashCode() : 0) );
    return ret;
    //@Override
    public int compareTo(Build other) {
    if(other!=null) {
    return this.hashCode() - other.hashCode();
    return -1;
    //@Override
    public String toString() { 
    String attr1= " date=" +( getDate() !=null ? ""+ getDate() : "NOT SET" );
    String attr2= " number=" +( getNumber() !=null ? ""+ getNumber() : "NOT SET" );
    String id = " buildId=" + ( getBuildId() !=null ? ""+ getBuildId() : "NOT SET" );
    return attr1 + attr2 + id ;
    //@Override
    public boolean equals(Object obj) {
    if (obj == null) {
    return false;
    if (obj == this) {
    return true;
    if (!(obj instanceof Build)) {
    return false;
    Build other = (Build) obj;
    return (buildId !=null ? buildId.equals(other.buildId) : other.buildId !=null ? false:true) && ( date !=null ? date.equals(other.date) : other.date !=null ? false:true ) && ( number !=null ? number.equals(other.number) : other.number !=null ? false:true );
    public Build clone() {
    Build ret= new Build();
    ret.setBuildId(buildId);
    ret.setDate(this.getDate());
    ret.setNumber(this.getNumber());
    return ret;
    package com.xilinx.srs.jpa.autogen;
    import java.io.Serializable;
    import java.util.*;
    import javax.persistence.*;
    @Entity
    public class SWRelease implements Serializable, Comparable<SWRelease> {
    private static final int HASH_PRIME=37;
    private static final long serialVersionUID = 1L;
    //Attribute list
    @Id
    @GeneratedValue
    private Integer releaseId;
    @OneToMany(cascade=CascadeType.ALL, mappedBy="mySWRelease", fetch=FetchType.LAZY)
    private Set<Build> myBuilds = new TreeSet<Build>();
    @Column(name="name")
    private String name;
    @Column(name="version")
    private String version;
    public SWRelease() {
    super();
    public void setReleaseId(Integer in) {
    this.releaseId = in;
    public Integer getReleaseId() {
    return this.releaseId ;
    public String getName() {
    return name;
    public void setName(String in) {
    this.name=in;
    public String getVersion() {
    return version;
    public void setVersion(String in) {
    this.version=in;
    * Setter for the many side of OneToMany mapping to <code>Build</code>.
    * @param in will assing myBuilds to in
    public void setBuilds (Set<Build> in) {
    this.myBuilds=in;
    public Set<Build> getBuilds() {
    return myBuilds;
    public int hashCode() { 
    int ret=0;
    ret = HASH_PRIME * (ret + (name !=null ? name.hashCode() : 0));
    ret = HASH_PRIME * (ret + (version !=null ? version.hashCode() : 0));
    ret = HASH_PRIME * (ret + (releaseId !=null ? releaseId .hashCode() : 0) );
    return ret;
    public int compareTo(SWRelease other) {
    if(other!=null) {
    return this.hashCode() - other.hashCode();
    return -1;
    public String toString() { 
    String attr1= " name=" +( getName() !=null ? ""+ getName() : "NOT SET" );
    String attr2= " version=" +( getVersion() !=null ? ""+ getVersion() : "NOT SET" );
    String id = " releaseId=" + ( getReleaseId() !=null ? ""+ getReleaseId() : "NOT SET" );
    return attr1 + attr2 + id ;
    public boolean equals(Object obj) {
    if (obj == null) {
    return false;
    if (obj == this) {
    return true;
    if (!(obj instanceof SWRelease)) {
    return false;
    SWRelease other = (SWRelease) obj;
    return (releaseId !=null ? releaseId.equals(other.releaseId) : other.releaseId !=null ? false:true) && ( name !=null ? name.equals(other.name) : other.name !=null ? false:true ) && ( version !=null ? version.equals(other.version) : other.version !=null ? false:true );
    //@Override
    public SWRelease clone() {
    SWRelease ret= new SWRelease();
    ret.setReleaseId(releaseId);
    ret.setName(this.getName());
    ret.setVersion(this.getVersion());
    return ret;
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
    persistence_1_0.xsd" version="1.0">
    <persistence-unit name="test" >
    <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    <class>com.xilinx.srs.jpa.autogen.Build</class>
    <class>com.xilinx.srs.jpa.autogen.SWRelease</class>
    <properties>
    <!-- Provider-specific connection properties -->
    <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
    <property name="toplink.jdbc.url" value="jdbc:mysql://xcort02:3306/whyme"/>
    <property name="toplink.jdbc.user" value="me"/>
    <property name="toplink.jdbc.password" value="whyme"/>
    <!-- Provider-specific settings -->
    <property name="toplink.ddl-generation" value="none"/>
    <property name="toplink.logging.level" value="FINEST" />
    <property name="toplink.create-ddl-jdbc-file-name" value="test-create-tables.sql"/>
    <property name="toplink.drop-ddl-jdbc-file-name" value="test-drop-drop.sql"/>
    <property name="toplink.target-database" value="MySQL4"/>
    <property name="toplink.cache.type.default" value="SoftWeak" />
    <property name="toplink.jdbc.write-connections.max" value="1" />
    <property name="toplink.jdbc.write-connections.min" value="1" />
    <property name="toplink.jdbc.read-connections.max" value="1" />
    <property name="toplink.jdbc.read-connections.min" value="1" />
    <property name="toplink.weaving" value="true"/>
    </properties>           
         </persistence-unit>
    </persistence>
    Here is the log trace:
    [TopLink Finest]: 2008.04.17 05:43:55.611--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.weaving; value=true
    [TopLink Finest]: 2008.04.17 05:43:55.678--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.orm.throw.exceptions; default value=true
    [TopLink Finer]: 2008.04.17 05:43:55.678--ServerSession(5462872)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/home/brotelan/sandboxes/HEAD/env/Misc/ReleaseTools/lib/jexcelapi/build/
    [TopLink Config]: 2008.04.17 05:43:56.264--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.SWRelease] is being defaulted to: SWRelease.
    [TopLink Config]: 2008.04.17 05:43:56.269--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.SWRelease] is being defaulted to: SWRELEASE.
    [TopLink Config]: 2008.04.17 05:43:56.313--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.SWRelease.releaseId] is being defaulted to: RELEASEID.
    [TopLink Config]: 2008.04.17 05:43:56.417--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.Build] is being defaulted to: Build.
    [TopLink Config]: 2008.04.17 05:43:56.418--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.Build] is being defaulted to: BUILD.
    [TopLink Config]: 2008.04.17 05:43:56.422--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.Build.buildId] is being defaulted to: BUILDID.
    [TopLink Config]: 2008.04.17 05:43:56.487--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.Person] is being defaulted to: Person.
    [TopLink Config]: 2008.04.17 05:43:56.487--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.Person] is being defaulted to: PERSON.
    [TopLink Config]: 2008.04.17 05:43:56.490--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.Person.ssn] is being defaulted to: SSN.
    [TopLink Config]: 2008.04.17 05:43:56.556--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.String com.xilinx.srs.jpa.autogen.Address.streetAddress2] is being defaulted to: STREETADDRESS2.
    [TopLink Config]: 2008.04.17 05:43:56.557--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.String com.xilinx.srs.jpa.autogen.Address.state] is being defaulted to: STATE.
    [TopLink Config]: 2008.04.17 05:43:56.560--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.Address.zip] is being defaulted to: ZIP.
    [TopLink Config]: 2008.04.17 05:43:56.561--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.String com.xilinx.srs.jpa.autogen.Address.streetAddress1] is being defaulted to: STREETADDRESS1.
    [TopLink Config]: 2008.04.17 05:43:56.562--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.String com.xilinx.srs.jpa.autogen.Address.city] is being defaulted to: CITY.
    [TopLink Config]: 2008.04.17 05:43:56.629--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.Job] is being defaulted to: Job.
    [TopLink Config]: 2008.04.17 05:43:56.630--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.Job] is being defaulted to: JOB.
    [TopLink Config]: 2008.04.17 05:43:56.632--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.Job.jobId] is being defaulted to: JOBID.
    [TopLink Config]: 2008.04.17 05:43:56.640--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.Company] is being defaulted to: Company.
    [TopLink Config]: 2008.04.17 05:43:56.641--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.Company] is being defaulted to: COMPANY.
    [TopLink Config]: 2008.04.17 05:43:56.643--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.Company.companyId] is being defaulted to: COMPANYID.
    [TopLink Config]: 2008.04.17 05:43:56.646--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.Requirement] is being defaulted to: Requirement.
    [TopLink Config]: 2008.04.17 05:43:56.647--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.Requirement] is being defaulted to: REQUIREMENT.
    [TopLink Config]: 2008.04.17 05:43:56.666--ServerSession(5462872)--Thread(Thread[main,5,main])--The alias name for the entity class [class com.xilinx.srs.jpa.autogen.RequirementNumber] is being defaulted to: RequirementNumber.
    [TopLink Config]: 2008.04.17 05:43:56.667--ServerSession(5462872)--Thread(Thread[main,5,main])--The table name for entity [class com.xilinx.srs.jpa.autogen.RequirementNumber] is being defaulted to: REQUIREMENTNUMBER.
    [TopLink Config]: 2008.04.17 05:43:56.669--ServerSession(5462872)--Thread(Thread[main,5,main])--The column name for element [private java.lang.Integer com.xilinx.srs.jpa.autogen.RequirementNumber.number] is being defaulted to: NUMBER.
    [TopLink Config]: 2008.04.17 05:43:56.680--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [private java.util.Set com.xilinx.srs.jpa.autogen.Company.myJobs] is being defaulted to: class com.xilinx.srs.jpa.autogen.Job.
    [TopLink Config]: 2008.04.17 05:43:56.908--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [private com.xilinx.srs.jpa.autogen.Company com.xilinx.srs.jpa.autogen.Job.myCompany] is being defaulted to: class com.xilinx.srs.jpa.autogen.Company.
    [TopLink Config]: 2008.04.17 05:43:56.929--ServerSession(5462872)--Thread(Thread[main,5,main])--The primary key column name for the mapping element [private com.xilinx.srs.jpa.autogen.Company com.xilinx.srs.jpa.autogen.Job.myCompany] is being defaulted to: COMPANYID.
    [TopLink Config]: 2008.04.17 05:43:56.929--ServerSession(5462872)--Thread(Thread[main,5,main])--The foreign key column name for the mapping element [private com.xilinx.srs.jpa.autogen.Company com.xilinx.srs.jpa.autogen.Job.myCompany] is being defaulted to: MYCOMPANY_COMPANYID.
    [TopLink Config]: 2008.04.17 05:43:56.930--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [protected java.util.Set com.xilinx.srs.jpa.autogen.SWRelease.myBuilds] is being defaulted to: class com.xilinx.srs.jpa.autogen.Build.
    [TopLink Config]: 2008.04.17 05:43:56.941--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [protected com.xilinx.srs.jpa.autogen.SWRelease com.xilinx.srs.jpa.autogen.Build.mySWRelease] is being defaulted to: class com.xilinx.srs.jpa.autogen.SWRelease.
    [TopLink Config]: 2008.04.17 05:43:56.942--ServerSession(5462872)--Thread(Thread[main,5,main])--The primary key column name for the mapping element [protected com.xilinx.srs.jpa.autogen.SWRelease com.xilinx.srs.jpa.autogen.Build.mySWRelease] is being defaulted to: RELEASEID.
    [TopLink Config]: 2008.04.17 05:43:56.943--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [private java.util.Set com.xilinx.srs.jpa.autogen.RequirementNumber.myRequirements] is being defaulted to: class com.xilinx.srs.jpa.autogen.Requirement.
    [TopLink Config]: 2008.04.17 05:43:56.944--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [private com.xilinx.srs.jpa.autogen.RequirementNumber com.xilinx.srs.jpa.autogen.Requirement.myRequirementNumber] is being defaulted to: class com.xilinx.srs.jpa.autogen.RequirementNumber.
    [TopLink Config]: 2008.04.17 05:43:56.945--ServerSession(5462872)--Thread(Thread[main,5,main])--The primary key column name for the mapping element [private com.xilinx.srs.jpa.autogen.RequirementNumber com.xilinx.srs.jpa.autogen.Requirement.myRequirementNumber] is being defaulted to: NUMBER.
    [TopLink Config]: 2008.04.17 05:43:56.945--ServerSession(5462872)--Thread(Thread[main,5,main])--The foreign key column name for the mapping element [private com.xilinx.srs.jpa.autogen.RequirementNumber com.xilinx.srs.jpa.autogen.Requirement.myRequirementNumber] is being defaulted to: MYREQUIREMENTNUMBER_NUMBER.
    [TopLink Config]: 2008.04.17 05:43:56.946--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [private com.xilinx.srs.jpa.autogen.Person com.xilinx.srs.jpa.autogen.Job.myPerson] is being defaulted to: class com.xilinx.srs.jpa.autogen.Person.
    [TopLink Config]: 2008.04.17 05:43:56.947--ServerSession(5462872)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [com.xilinx.srs.jpa.autogen.Job com.xilinx.srs.jpa.autogen.Person.work] is being defaulted to: class com.xilinx.srs.jpa.autogen.Job.
    [TopLink Config]: 2008.04.17 05:43:56.948--ServerSession(5462872)--Thread(Thread[main,5,main])--The primary key column name for the mapping element [com.xilinx.srs.jpa.autogen.Job com.xilinx.srs.jpa.autogen.Person.work] is being defaulted to: JOBID.
    [TopLink Config]: 2008.04.17 05:43:56.949--ServerSession(5462872)--Thread(Thread[main,5,main])--The foreign key column name for the mapping element [com.xilinx.srs.jpa.autogen.Job com.xilinx.srs.jpa.autogen.Person.work] is being defaulted to: WORK_JOBID.
    [TopLink Config]: 2008.04.17 05:43:56.958--ServerSession(5462872)--Thread(Thread[main,5,main])--The source primary key column name for the many to many mapping [private java.util.Set com.xilinx.srs.jpa.autogen.Person.myRelations] is being defaulted to: SSN.
    [TopLink Config]: 2008.04.17 05:43:56.971--ServerSession(5462872)--Thread(Thread[main,5,main])--The target primary key column name for the many to many mapping [private java.util.Set com.xilinx.srs.jpa.autogen.Person.myRelations] is being defaulted to: SSN.
    [TopLink Finer]: 2008.04.17 05:43:56.984--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.SWRelease].
    [TopLink Finer]: 2008.04.17 05:43:56.985--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.Build].
    [TopLink Finer]: 2008.04.17 05:43:56.990--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.Person].
    [TopLink Finer]: 2008.04.17 05:43:56.990--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.Job].
    [TopLink Finer]: 2008.04.17 05:43:56.991--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.Company].
    [TopLink Finer]: 2008.04.17 05:43:56.991--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.Requirement].
    [TopLink Finer]: 2008.04.17 05:43:56.992--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver processing class [com.xilinx.srs.jpa.autogen.RequirementNumber].
    [TopLink Finest]: 2008.04.17 05:43:57.001--ServerSession(5462872)--Thread(Thread[main,5,main])--end predeploying Persistence Unit test; state Predeployed; factoryCount 0
    [TopLink Finer]: 2008.04.17 05:43:57.002--Thread(Thread[main,5,main])--javaSECMPInitializer - registering transformer for test.
    [TopLink Finest]: 2008.04.17 05:43:57.514--ServerSession(5462872)--Thread(Thread[main,5,main])--begin predeploying Persistence Unit test; state Predeployed; factoryCount 0
    [TopLink Finest]: 2008.04.17 05:43:57.518--ServerSession(5462872)--Thread(Thread[main,5,main])--end predeploying Persistence Unit test; state Predeployed; factoryCount 1
    [TopLink Finest]: 2008.04.17 05:43:57.528--ServerSession(5462872)--Thread(Thread[main,5,main])--begin deploying Persistence Unit test; state Predeployed; factoryCount 1
    [TopLink Finer]: 2008.04.17 05:43:57.663--ServerSession(5462872)--Thread(Thread[main,5,main])--Weaver transformed class [com/xilinx/srs/jpa/autogen/Build].
    [TopLink Finest]: 2008.04.17 05:43:57.752--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.logging.level; value=FINEST; translated value=FINEST
    [TopLink Finest]: 2008.04.17 05:43:57.752--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.logging.level; value=FINEST; translated value=FINEST
    [TopLink Finest]: 2008.04.17 05:43:57.756--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.user; value=root
    [TopLink Finest]: 2008.04.17 05:43:57.757--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.password; value=xxxxxx
    [TopLink Finest]: 2008.04.17 05:43:58.824--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.target-database; value=MySQL4; translated value=oracle.toplink.essentials.platform.database.MySQL4Platform
    [TopLink Finest]: 2008.04.17 05:43:58.829--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.driver; value=com.mysql.jdbc.Driver
    [TopLink Finest]: 2008.04.17 05:43:58.829--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.url; value=jdbc:mysql://xcort02:3306/brotelan_test
    [TopLink Finest]: 2008.04.17 05:43:58.830--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.write-connections.min; value=1
    [TopLink Finest]: 2008.04.17 05:43:58.830--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.write-connections.max; value=1
    [TopLink Finest]: 2008.04.17 05:43:58.830--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.read-connections.min; value=1
    [TopLink Finest]: 2008.04.17 05:43:58.830--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.jdbc.read-connections.max; value=1
    [TopLink Finest]: 2008.04.17 05:43:58.831--ServerSession(5462872)--Thread(Thread[main,5,main])--property=toplink.cache.type.default; value=SoftWeak; translated value=oracle.toplink.essentials.internal.identitymaps.SoftCacheWeakIdentityMap
    [TopLink Info]: 2008.04.17 05:43:58.844--ServerSession(5462872)--Thread(Thread[main,5,main])--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))
    [TopLink Config]: 2008.04.17 05:43:58.867--ServerSession(5462872)--Connection(18511266)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
    platform=>MySQL4Platform
    user name=> "root"
    datasource URL=> "jdbc:mysql://xcort02:3306/brotelan_test"
    [TopLink Config]: 2008.04.17 05:43:59.462--ServerSession(5462872)--Connection(7100506)--Thread(Thread[main,5,main])--Connected: jdbc:mysql://xcort02:3306/brotelan_test
    User: [email protected]
    Database: MySQL Version: 5.0.51a
    Driver: MySQL-AB JDBC Driver Version: mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )
    [TopLink Config]: 2008.04.17 05:43:59.463--ServerSession(5462872)--Connection(18655235)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
    platform=>MySQL4Platform
    user name=> "root"
    datasource URL=> "jdbc:mysql://xcort02:3306/brotelan_test"
    [TopLink Config]: 2008.04.17 05:43:59.498--ServerSession(5462872)--Connection(2569862)--Thread(Thread[main,5,main])--Connected: jdbc:mysql://xcort02:3306/brotelan_test
    User: [email protected]
    Database: MySQL Version: 5.0.51a
    Driver: MySQL-AB JDBC Driver Version: mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )
    [TopLink Finest]: 2008.04.17 05:43:59.544--ServerSession(5462872)--Thread(Thread[main,5,main])--sequencing connected, state is Preallocation_Transaction_NoAccessor_State
    [TopLink Finest]: 2008.04.17 05:43:59.545--ServerSession(5462872)--Thread(Thread[main,5,main])--sequence SEQ_GEN: preallocation size 50
    [TopLink Info]: 2008.04.17 05:43:59.938--ServerSession(5462872)--Thread(Thread[main,5,main])--file:/home/brotelan/sandboxes/HEAD/env/Misc/ReleaseTools/lib/jexcelapi/build/-test login successful
    [TopLink Finest]: 2008.04.17 05:43:59.938--ServerSession(5462872)--Thread(Thread[main,5,main])--end deploying Persistence Unit test; state Deployed; factoryCount 1
    [TopLink Finer]: 2008.04.17 05:43:59.990--ServerSession(5462872)--Thread(Thread[main,5,main])--client acquired
    [TopLink Finest]: 2008.04.17 05:44:00.017--UnitOfWork(7318012)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(com.xilinx.srs.jpa.autogen.SWRelease)
    [TopLink Fine]: 2008.04.17 05:44:00.072--ServerSession(5462872)--Connection(7100506)--Thread(Thread[main,5,main])--SELECT RELEASEID, name, version FROM SWRELEASE WHERE (RELEASEID = ?)
    bind => [2]
    [TopLink Finest]: 2008.04.17 05:44:00.123--UnitOfWork(7318012)--Thread(Thread[main,5,main])--Register the existing object name=Lava version=11.1 releaseId=2
    [TopLink Finest]: 2008.04.17 05:44:00.146--UnitOfWork(7318012)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(com.xilinx.srs.jpa.autogen.SWRelease)
    [TopLink Fine]: 2008.04.17 05:44:00.147--ServerSession(5462872)--Connection(7100506)--Thread(Thread[main,5,main])--SELECT RELEASEID, name, version FROM SWRELEASE WHERE (RELEASEID = ?)
    bind => [3]
    [TopLink Finest]: 2008.04.17 05:44:00.148--UnitOfWork(7318012)--Thread(Thread[main,5,main])--Register the existing object name=Magma version=12.1 releaseId=3
    Lava release builds: {IndirectSet: not instantiated}
    Magma release builds: {IndirectSet: not instantiated}

    Google print capable?

  • Implementing Comparable interface? Help please.

    Why am I getting the following error?
    Exception in thread "main" java.lang.ClassCastException: java.lang.Double cannot be cast to chapter10.RectangleJust look at the test class and ComparableRectangle class if you can find the bug.
    Here are the 3 of 4 classes:
    package chapter10;
    public class TestComparableRectangle {
        public static void main (String[] args) {
            ComparableRectangle area1 = new ComparableRectangle(3.0, 6.0);
            ComparableRectangle area2 = new ComparableRectangle(5.0, 4.0);
            int result = area1.compareTo(area2.getArea());
            if (result == -1)
                System.out.println("area1 " + area1.getArea() + " < "
                        + area2.getArea() + " area2.");
            else if (result == 0)
                System.out.println("area1 " + area1.getArea() + " = "
                        + area2.getArea() + " area2.");
            else
                System.out.println("area1 " + area1.getArea() + " > "
                        + area2.getArea() + " area2.");
    package chapter10;
    public class ComparableRectangle extends Rectangle implements Comparable{
        /** Construct a ComprableRectangle with specified properties */
        public ComparableRectangle(double width, double height) {
            super(width, height);
        /*  Implement the compareTo method defined in Comparable */
        @Override
        public int compareTo(Object x) {
            if (getArea() > ((Rectangle)x).getArea())
                return 1;
            else if (getArea() < ((Rectangle)x).getArea())
                return -1;
            else
                return 0;
    package chapter10;
    public class Rectangle extends GeometricObject {
        private double width;
        private double height;
        public Rectangle(){
        public Rectangle (double width, double height) {
            this.width = width;
            this.height = height;
        // Return width
        public double getWidth () {
            return width;
        // Set a new width
        public void setWidth (double width) {
            this.width = width;
        // Return height
        public double getHeight () {
            return height;
        public void setHeight (double height) {
            this.height = height;
        // Return area
        public double getArea () {
            return width * height;
        //Return parimeter
        public double getPerimeter() {
            return 2 * (width + height);
    }Thanks in advance.

    Thanks a lot friend. It has been a week I've been trying to find the problem. In fact I was adding/casting the left side, but never tried the right side.
    This is what I changed it and it worked.
    int result = area1.compareTo(area2);Thank you.

  • Implements Comparable error

    Hi,
    I've got code like that:
    import java.lang.Comparable;
    import java.util.*;
    * @author Adam
    public class Person implements Comparable { //this line causes error
        /** Creates a new instance of Person */
        public Person() {
        }I've got also another class DataBase, where I have ArrayList of Person, I would like to sort them by surname, in clas person I have also methods like that:
            public boolean equals(Object o)
            if (!(o instanceof Person))
                return false;
            Person n = (Person)o;
            return n.surname.equals(surname);
            public int compareTo(Person n)
             int lastCmp = surname.compareTo(n.surname);
             return (lastCmp != 0 ? lastCmp :
                    surname.compareTo(n.surname));
              public int hashCode()
               return 31*surname.hashCode();
              }My Error is: Person is not abstract and does not override abstract method compareTo(java.lang.Object) in java.lang.Comparable
    But class Person shouldn't be abstract, te line which causes the error is: public class Person implements Comparable, I don't know why. Can enyone help me?

    So I'll try to create abstract class with different
    name.
    But here->http://www.onjava.com/lpt/a/3286 they don't
    have any problems with implementing this.
    Message was edited by:
    snakeomwhy do you think you want an abstract class??
    you've got a perfectly good tutorial right there, that tells you exactly what you need to do. just follow that. read your code again and see if there's anything in your first class that does any comparing (clue: there isn't)

  • Sorting and CopyOnWriteArrayList

    Hi,
    Last week I found myself working around the following problem: I have a list of data that is being searched already while new data is still added. Knowing to take care of the dreaded ConcurrentModificationException, I chose the [url http://download.oracle.com/javase/6/docs/api/java/util/concurrent/CopyOnWriteArrayList.html]CopyOnWriteArrayList implementation and I discovered that that class does not play well with Collections.sort():
    import java.util.Collections;
    import java.util.List;
    import java.util.concurrent.CopyOnWriteArrayList;
    public class OTNConcurrentArrayListSorting {
         public static void main(String[] args) {
              List<String> l = new CopyOnWriteArrayList<String>();
              l.add("oracle");
              l.add("java");
              Collections.sort(l);
    }leads to:
    Exception in thread "main" java.lang.UnsupportedOperationException
         at java.util.concurrent.CopyOnWriteArrayList$COWIterator.set(CopyOnWriteArrayList.java:1013)
         at java.util.Collections.sort(Collections.java:121)
         at OTNConcurrentArrayListSorting.main(OTNConcurrentArrayListSorting.java:12)This came as a surprise to me, but it is documented and after a bit of thinking quite understandable. After all what good is sorting if new elements are added to the list unseen and not taken into account in the sort.
    The way I worked around it, is using a binary search to find out where to add the new element and thus keeping the list sorted at all times. Only in preparation of this post, it occurred to me that I'd need the additions to be synchronized for that idea to work, so I ended up with this fragment:
    synchronized (revolutions) {
         int i = Collections.binarySearch(revolutions, info);
         if (i < 0) {
              revolutions.add(-(i+1), info);
    }I am not unhappy with the solution and it serves the purpose, but still I wonder whether there's a better alternative. Any ideas?

    Great suggestion! The list I am maintaining is a sort of index for elements like this, where the number is positive and the interval is a start and end date (the intervals are non overlapping and their sorting goes hand-in-hand with the number):
          * Packs the revolution number and the date range covered by it,
          * while {@link #compareTo(RevolutionInfo)} orders according to the number.
         private static class RevolutionInfo implements Comparable<RevolutionInfo>{
              int number;
              Interval span;
              @Override
              public String toString() {
                   return "Revolution "+number+" "+ span.toString();               
              @Override
              public int compareTo(RevolutionInfo o) {
                   return number - o.number;
         }I need to support both a search by number to retrieve the Interval of dates (an exact match, will work very well with the HashMap) and a search by date to get the revolution number. The two are now unified in one piece of search code and two different Comparator implementations.
    I am already maintaining an underlying datastructure in a HashMap, which I could use to improve the by number lookup-performance. By the way, the main (and measured) performance penalty I am trying to avoid is the following. I have a datastructure SkyMap, one per revolution (we'll reach 1000 in a couple of weeks) which I read from a 2 Mb XML-file (which is 400 maps, benchmarked at ~8 maps per second). In one use case, all the maps are alredy pre-loaded and can be served out of memory. In a much rarer use case, the maps are being loaded and a request (get number for a given date) needs to be handled: it's here that I want to remove the overhead of waiting for the entire file to be processed, but go about the business as soon as the SkyMap covering that date is available.

Maybe you are looking for

  • PDFMaker icon not working in Acrobat Pro 8.3.1.

    I am using  OS Windows XP Home and Microsoft Office 2003. I generally use the work around of "Print". Annoying that I cannot use the PDFMaker icon in any Microsoft products. It use to work flawlessly. I keep getting the annoying message "The acrobat

  • Help with jquery code into iweb

    Hello, I am new to inserting code into iweb and was wondering if it was possible to use code such as the jquery plugins into an iweb html snippet? i would like to create a simple image gallery such as the following link: http://malsup.com/jquery/cycl

  • Dropping in PDF files into iDVD? How?

    I have a client who would like to put some PDF files as well as video into a DVD I am making for here. What is the best way to throw some PDF's in? I would like a button that would point to those. Any help would be greatly appreciated? Best, Tom

  • Where to install Camera Raw 3.7?

    I downloaded Camera Raw 3.7 Update (MacOS X) , but cannot figure out where both Lightroom and CS2 want to find it. I can't even find any existing instance of Camera raw although it must be b somewhere on my machine.

  • Question Marks in Dock

    My computer had been having problems so I went to the genius bar and they reinstalled Leopard for me. Now I'm trying to change all my settings back to how they were but iPhoto and iMovie show up as question marks in the dock. What's going on?