I need to query in HQL and I have this Hibernate entity.
@Entity
@Table(name = "TB_TIPO_DOCT", schema = "FEP")
@NamedQueries({
@NamedQuery(name = "TbTipoDoct.findAllDocumentosLiberados", query =
"SELECT t FROM TbTipoDoct t WHERE t.cdSituCnfr IS NULL ORDER BY
t.dsTipoDoct"),
@NamedQuery(name = "TbTipoDoct.findAllDocumentosNaoLiberados", query =
"SELECT t FROM TbTipoDoct t WHERE t.cdSituCnfr IS NOT NULL ORDER BY
t.dsTipoDoct") })
public class TbTipoDoct implements Serializable {
private static final long serialVersionUID = 1492325815547842716L;
@Id
@Basic(optional = false)
@Column(name = "NR_SEQU_TIPO_DOCT")
private Long nrSequTpDoct;
@Column(name = "CD_DOCT")
private Integer cdDoct;
What% of what I do is:
SELECT * FROM FEP.TB_TIPO_DOCT WHERE NR_SEQU_TIPO_DOCT = 259;
My HQL query:
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.getCurrentSession();
Query query = session.createQuery("from TbTipoDoct tb where tb.nrSequTpDoct=
:259");
Is it correct?