I have a Class-Entity Product.
@Entity
public class Produto implements Serializable{
@Id
@GeneratedValue
private long id;
@Column(length = 70, nullable = false)
private String cod;
@Column(length = 100, nullable = false)
private String descricao;
@Column
@OneToOne
@JoinColumn(name = "idUnComer")
private Unidade unComer;//unidade comercial
}
However, when I do the query:
Select prod.id as id,prod.cod as cod,prod.descricao as descricao,prod.unComer as unComer from Produto prod
It does not list if there is no commercial unit saved. Only entering the values where the foreign key was filled in.
Now if I do this:
from Produto
It lists all the records, having null foreign keys or not.
In fact my product contains several other fields, but I just wanted to list the bank only a few that I need.
Has anyone ever been through this?
I'm using Hibernate 4.3 and mysql 5.6.