I have two classes. A Weather class and a Book class. ( Don't pay any
attention to why a Weather can have books :) )

Anyway. The Weather class has an ArrayList of Books and the book has a
Weather.

See code below.

===========================================
package samples.demo;

import java.io.Serializable;
import java.util.ArrayList;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;



@Entity()
@Table( name = "Weather" , schema = "Hello" )
@SuppressWarnings( "serial" )
public class Weather implements Serializable{
        
        @Id()
        @GeneratedValue()
        @Column( name = "WeatherId" )
        Long id;
        
        @Column( name = "Temperature"  )
    float temperature;
        @Column( name = "Forecast"  )
    String forecast;
        @Column( name = "Rain"  )
    boolean rain;
        @Column( name = "HowMuchRain"  )
    float howMuchRain;
        
        @OneToMany( mappedBy = "weather",  fetch = FetchType.EAGER )
        @JoinColumn( name = "WeatherId" )
        ArrayList<Book> books = new ArrayList<Book>();
        
        public Weather(){
                
        }
    
    public void setTemperature(float temp){
        temperature = temp;
    }

    public float getTemperature(){
        return temperature;
    }
    
    public void setForecast(String fore){
        forecast = fore;
    }

    public String getForecast(){
        return forecast;
    }
    
    public void setRain(boolean r){
        rain = r;
    }

    public boolean getRain(){
        return rain;
    }
    
    public void setId( Long id ){
          this.id = id;
    }
    
    public void setHowMuchRain(float howMuch){
        howMuchRain = howMuch;
    }

    public float getHowMuchRain(){
        return howMuchRain;
    }

        public Long getId() {
                return id;
        }
        
        public boolean equals(Object obj) {
                
                if( obj == null ){
                        return false;
                }
                if( obj instanceof Weather ) {
                        return ((Weather)obj).getId().equals( getId() );
                }
                return false;
        }
        
        public int hashCode() {
                return id.hashCode();
        }

        public ArrayList<Book> getBooks() {
                return books;
        }

        
        public void addBook( Book b ){
                books.add(b);
                //b.setWeather(this);
        }

}
==========================================

Book
==========================================
package samples.demo;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;


@Entity()
@Table( name = "Book" , schema = "Hello" )
@SuppressWarnings( "serial" )
public class Book implements Serializable{
        
        @Id()
        @GeneratedValue()
        @Column( name = "BookId" )
        Long id;
        
        @Column( name = "Title" )
    String title;
        @Column( name = "ISBN" )
    String isbn;
        @Column( name = "Author" )
    String author;
        @ManyToOne( cascade = CascadeType.REFRESH )
        @JoinColumn( name = "WeatherId" )
        private Weather weather;

        public Weather getWeather() {
                return weather;
        }

        public void setWeather(Weather weather) {
                this.weather = weather;
        }

        public Book(){
                
        }
        
    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }
    
    public Long getId(){
        return id;
    }
}

=======================================

When I try to send this I can send the Weather class to a client.
RPCServiceClient, but when I 
Do addBook it hangs?

This Works

Weather w = new Weather();
w.setForecast( "Cloud" );
w.setHowMuchRain(45.5f);
w.setRain(false);
w.setTemperature(45.23f);

return w;

This does not work

Weather w = new Weather();
w.setForecast( "Cloud" );
w.setHowMuchRain(45.5f);
w.setRain(false);
w.setTemperature(45.23f);
Book b = new Book();
b.setAuthor("Mathias Nilsson");
b.setIsbn("787812");
b.setTitle( "Java for ultra dummies 2");
b.setWeather(w);
w.addBook(b);

return w;



Any ideas? I really hope that I can send a object that has a collection of
objects?
-- 
View this message in context: 
http://www.nabble.com/can%27t-serialize-arraylist-tf4391821.html#a12521558
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to