Hibernate

Create a main class (SelectTest.java)
Previous Home Next

Step 5: Create a main class

SelectTest.java

package r4r;
import java.util.Scanner;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class SelectTest {
public static void main(String rr[])
{
Session session=SessionProvider.getSession();
Transaction t=session.beginTransaction();
// List<Emp> list=new List<Emp>;
Scanner in=new Scanner(System.in);
System.out.println("enter id:-");
int id=in.nextInt();
Emp e=(Emp)session.load(Emp.class,id);
System.out.println("followin records are fetched:-");
System.out.println(e.getId()+"\t"+e.getName()+
"\t"+e.getJob()+"\t"+e.getSalary());
t.commit();
session.close();
}
}
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: