Eclipselink: Create objects from JOIN query

Posted by Raven on Stack Overflow See other posts from Stack Overflow or by Raven
Published on 2010-04-05T11:37:21Z Indexed on 2010/04/05 11:43 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

Hi,

I have a SQL query

SELECT * FROM Thing AS a JOIN Thing_Property AS b ON a.id=b.Thing_ID 
   JOIN Property AS c ON b.properties_ID = c.id 
   JOIN Item AS d ON c.item_ID = d.id 
   ORDER BY a.name, d.name 

and I Eclipselink to create my object model with it. Here is the model:

@SuppressWarnings("serial")
@Entity
public class Thing implements Serializable {
     @Id
     @GeneratedValue(strategy = GenerationType.TABLE)
     private int id;
     private String name;
     @OneToMany(cascade=CascadeType.ALL)
     @PrivateOwned
     private List<Property> properties = new ArrayList<Property>();
     ...
     // getter and setter following here
}
public class Property implements Serializable { 
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private int id;

    @OneToOne
    private Item item;

     private String value;
     ...
     // getter and setter following here
}
public class Item implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    private int id;
    private String name;
     ....
     // getter and setter following here    
}
// Code end

but I can not figure out, how to make Eclipselink create the model from that query. Can you help?

© Stack Overflow or respective owner

Related posts about eclipselink

Related posts about eclipse