ObjectDB ObjectDB

List always null

#1

I have the following classes:


@Entity
public class Noticia implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @ManyToOne(targetEntity = Categoria.class)
    private List<Categoria> categorias;

 


@Entity
public class Categoria implements Serializable {
   
    private static final long serialVersionUID = 1L;
   
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @OneToMany(targetEntity = Noticia.class, mappedBy = "categorias", cascade = CascadeType.PERSIST)
    private List<Noticia> noticias;

I'm trying to save an object of class Noticia, and update the list of class Categoria. This makes it well, but to retrieve the object Categoria, the list is null always.

What can it be?

I leave a snapshot in which it can be see clearly: http://i1134.photobucket.com/albums/m617/David7_AP/Sintiacutetulo_zps1728676e.png

edit
delete
#2

Your query is invalid because you cannot specify collection fields in the SELECT clause.

Try:

SELECT n FROM Categoria c JOIN c.noticias n WHERE c.id = 1
ObjectDB Support
edit
delete

Reply

To post on this website please sign in.