users@glassfish.java.net

data lost on serialization

From: <glassfish_at_javadesktop.org>
Date: Sun, 27 Apr 2008 14:41:22 PDT

Hello,
I have a strange problem while calling a slsb. I get my vertical class out of the db, copy them to a new list and return them. On the client side when I
read the class it has no properties. I've never seen this before. What could cause vertical.name to not serialize and be null on the client side? The log output at the bottom shows the missing data.

stateless bean code:
...
public List<Vertical> list() {
    List<Vertical> verticals = verticalDao.list();
    ArrayList list = new ArrayList(verticals.size());

    for(Vertical vertical : verticals)
        list.add(new Vertical(vertical));

    if(LOG.isLoggable(Level.FINE))
        LOG.fine("list=" + list);

    return list;
}
...


spring client code:
...
@RequestMapping("list.do")
    public void list(ModelMap model) {
        List<Vertical> list = verticalService.list();
        LOG.fine("list=" + list);
        model.addAttribute("verticals", list);
    }
...

Enity:
/**
 */
@Entity
public class Vertical implements Serializable {

    private Long id;
    private int version;
    private String name;
    private Vertical parent;

    private Set<Offer> offers;

    public Vertical(Vertical copy) {
        this.name = copy.getName();
        this.id = copy.getId();
    }

    public Vertical() {
    }

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator = "vertical_seq")
    @SequenceGenerator(name="vertical_seq", sequenceName = "vertical_seq")
    @Column(name = "vertical_id")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }



Log output:
[#|2008-04-27T16:57:12.687-0400|FINE|sun-appserver9.1|com.turnTwoMedia.core.vertical.VerticalServiceImpl|_ThreadID=29;_ThreadName=TP-Processor3;ClassName=com.turnTwoMedia.core.vertical.VerticalServiceImpl;MethodName=list;_RequestID=dd889462-68a2-426f-a395-8a4c1bafd6d4;|list=[com.turnTwoMedia.core.vertical.Vertical_at_17e4e74c[id=1,name=Parent Vertical], com.turnTwoMedia.core.vertical.Vertical_at_350d3ad5[id=51,name=Test Child Vertical], com.turnTwoMedia.core.vertical.Vertical_at_77919128[id=101,name=]]|#]

[#|2008-04-27T16:57:12.690-0400|FINE|sun-appserver9.1|com.turnTwoMedia.t2m2.spring.vertical.VerticalController|_ThreadID=29;_ThreadName=TP-Processor3;ClassName=com.turnTwoMedia.t2m2.spring.vertical.VerticalController;MethodName=list;_RequestID=dd889462-68a2-426f-a395-8a4c1bafd6d4;|list=[com.turnTwoMedia.core.vertical.Vertical_at_7fa4e85c[id=<null>,name=<null>], com.turnTwoMedia.core.vertical.Vertical_at_6174f249[id=<null>,name=<null>], com.turnTwoMedia.core.vertical.Vertical_at_e7a3346[id=<null>,name=<null>]]|#]



jvm 1.6
glassfish v2u1
using OpenJPA 1.0.2
spring-webmvc 2.5.3

Thanks in advance for any help.
Michael
[Message sent by forum member 'mfortin' (mfortin)]

http://forums.java.net/jive/thread.jspa?messageID=271729