[jboss-user] [EJB 3.0] - EJB3: org.hibernate.type.SerializationException: could not d

D6L do-not-reply at jboss.com
Tue Apr 28 00:47:58 EDT 2009


Hi everybody,
I would get an Output of an Table Road (Oracle Database) via EntityManager and Web Services. I got the following error :
org.hibernate.type.SerializationException: could not deserialize

Eclipe3.4.1/Glassfish V2.1/SoapUI 2.5 (for testing)

Enviroment:

  Class  :  Location                  
      IATA    (PK)                     
 Class  :  Road  
   Origin        (PK)(FK of IATA)
   Destination  (PK)(FK of IATA)
 
To manage the composite ID I generated a class RoadPK which is below:

import java.io.Serializable;
  | import javax.persistence.Embeddable;
  | @Embeddable
  | public class RoadPK  implements Serializable {
  |   
  |     /**
  |      * Variable of type Location
  |      */
  |     private Location origin = null;
  | 
  |     private Location destination = null;
  | ......(Getter/Setter).....
  | 

Class Road have the attributs(the composite ID).
 I locate the Problem here in the @nameQuery. I can show all availability methods when I write SELECT r.availabilityMethod  FROM ROADS r. 
But I can't access origin and destination by SELECT r.origin.iata FROM ROADS r . So my Question is: 
Is my mapping wrong or is there no posssibility to work with Type classes for attributes in composite IDs in EJB3?

@Entity
  | @NamedQuery(
  | 	name = "ROADS.listAll",
  | 	query = "SELECT r FROM ROADS r")/*
  | 
  | @Table(name="ROADS")
  | public class ROADS implements Serializable {
  | 
  |      private RoadPK  roadPK  = null;
  |      private String availabilityMethod = null;
  | 
  |     @EmbeddedId
  |     public RoadPK  getRoadPK() {
  | 	return roadPK  ;
  |     }
  |     
  |     public void setRoadPK(RoadPK  roadPK  ) {
  | 	this.roadPK  = roadPK  ;
  |    }
  |    @Column(name="AVAILABILITY_METHOD")
  |     public String getAvailabilityMethod() {
  |         return availabilityMethod;
  |     }
  | 
  |     
  |     public void setAvailabilityMethod(final String availabilityMethodParam) {
  |         this.availabilityMethod = availabilityMethodParam;
  |     }
  | 
  | 
  | }

Class Location:

@Entity
  | @Table(name = "LOCATIONS")
  | public class Location implements Serializable {
  |      
  |      private String iata = null;
  | 
  |      /**
  |      * The Roads
  |      */
  |      private Set<Road> roadsorigin;
  | 	
  |      private Set<Road> roadsdestination;
  | 
  |      @Id
  |      @Column(name = "IATA")
  |      public String getIata() {
  | 	return iata;
  |      }
  | //...................
  |     @OneToMany(mappedBy = "roadPK.origin", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  |     public Set<Road> getRoadsorigin() {
  |            return roadsorigin;
  |     }
  | 
  |     public void setRoadsorigin(Set<ROAD> roadsorigin) {
  | 	this.roadsorigin= roadsorigin;
  |     }
  | 
  |     @OneToMany(mappedBy = "roadPK.destination", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  |     public Set<Road> getRoadsdestination() {
  | 	return roadsdestination;
  |     }
  | 
  |     public void setRoadsdestination(Set<Road> roadsdestination) {
  | 	this.roadsdestination = roadsdestination;
  |     }
  | }

The class RoadDAO offers the WebServices:

@WebService
  | @Stateless(name="RoadDAO")
  | public class RoadDAOimplements Serializable {
  | 	
  |     @PersistenceContext(name="ResourceDS")
  |     private EntityManager em;
  |      //  ....
  |      @SuppressWarnings("unchecked")
  |     @WebMethod
  |     @WebResult(name="RoadsList")
  |      public final List < Road> listRoad() {
  |     	return em.createNamedQuery("Road.listAll").getResultList();
  |     }
  |     //  ....
  | }

Thanks for reading


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4227131#4227131

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4227131



More information about the jboss-user mailing list