1
good evening, I’m having the following problem.
I’m using JPA with Ormlite to make persistence on Android.
I created a class Produto
and a Categoria
, both inherit from an abstract class AbstractEntity
.
When consulting a product, it brings the category but only with the id
populous.
To descrição
and the imagem
comes as null
.
If I use the query separately, bringing only the category list, all fields are returned.
Follow the section of the class:
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractEntity implements Serializable {
private static final long serialVersionUID = 35L;
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
@Column(name = "descricao")
private String descricao;
@Column(name = "img")
private Integer img ;
public AbstractEntity()
{
}
}
@Entity(name="categoria")
public class Categoria extends AbstractEntity {
private static final long serialVersionUID = 35L;
public Categoria()
{
//this.setId(new Long(0));
//this.setDescricao("");
}
}
@Entity(name="produto")
public class Produto extends AbstractEntity {
private static final long serialVersionUID = 35L;
@ManyToOne(cascade=CascadeType.ALL)
private Categoria categoria;
public Produto()
{
//this.setId(new Long(0));
//this.setDescricao("");
//this.setImg(0);
///this.categoria = new Categoria();
}
}
How is your query? How are you evaluating the return of this query?
– Dherik