O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data tier implementation with Hibernate

Let's now see how the discussed patterns are applied to the application that directly uses Hibernate. The following code shows a sample DAO interface:

package com.packtpub.springhibernate.ch13;
import java.util.Collection;
public interface StudentDao {
public Student getStudent(long id);
public Collection getAllStudents();
public Collection getGraduatedStudents();
public Collection findStudents(String lastName);
public void saveStudent(Student std);
public void removeStudent(Student std);
}

The following code shows a DAO class that implements this DAO interface:

package com.packtpub.springhibernate.ch13; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required