Query q = sessionFactory.getCurrentSession().createQuery("from LoginInfo where userName = :name");
q.setParameter("name", userName);
List<LoginInfo> loginList = q.list();
You have other options too, see this nice article from mkyong.
More Related Contents:
- JPA JoinColumn vs mappedBy
- Hibernate throws MultipleBagFetchException – cannot simultaneously fetch multiple bags
- Hibernate Annotations – Which is better, field or property access?
- Hibernate JPA Sequence (non-Id)
- How to store date/time and timestamps in UTC time zone with JPA and Hibernate
- How to call a stored procedure from Java and JPA
- Bypass GeneratedValue in Hibernate (merge data not in db?)
- How does the FetchMode work in Spring Data JPA
- What is “the inverse side of the association” in a bidirectional JPA OneToMany/ManyToOne association?
- Prevent SQL injection attacks in a Java program
- Hibernate Union alternatives
- Hibernate – @ElementCollection – Strange delete/insert behavior
- Difference between @OneToMany and @ElementCollection?
- JPA SQL Server No Dialect mapping for JDBC type: -9
- Transaction marked as rollback only: How do I find the cause
- JPA entity without id
- Can I combine a @Query definition with a Specification in a Spring Data JPA repository method?
- How to use multiple JOIN FETCH in one JPQL query
- Multiple fetches with EAGER type in Hibernate with JPA
- Could not commit JPA transaction: Transaction marked as rollbackOnly
- Spring JpaRepository – Detach and Attach entity
- Native query with named parameter fails with “Not all named parameters have been set”
- Specifying an Index (Non-Unique Key) Using JPA
- IN-clause in HQL or Java Persistence Query Language
- @BatchSize a smart or stupid use?
- How to set the timeout period on a JPA EntityManager query
- Spring Data JPA and Exists query
- Error creating bean with name ‘entityManagerFactory
- How to force Hibernate to return dates as java.util.Date instead of Timestamp?
- JPA Select latest instance for each item