-
Hibernate problem i
I have done all configuration fro hibernate ,
My this code executed ----and display all fields
import java.util.ArrayList;
import org.hibernate.Session;
import org.hibernate.Query;
public class First {
public static void main(String args[])
{
First F =new First();
Person P =new Person();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
String query = "select p from Person p ";
Query q= session.createQuery(query);
ArrayList al=(ArrayList)q.list();
Person p1=(Person)al.get(0);
int x=p1.getId();
int y=p1.getAge();
String z=p1.getFirstname();
String k=p1.getLastname();
System.out.println("Person-Id---"+ x);
System.out.println("Age---"+y);
System.out.println("FirstName---"+z);
System.out.println("LastName---"+k);
//session.save(P);
session.getTransaction().commit();
}
}
My this code did not execute ----i am doing from this code insert value in database
import java.util.ArrayList;
import org.hibernate.Session;
import org.hibernate.Query;
public class First {
public static void main(String args[])
{
First F =new First();
Person P =new Person();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
P.setAge(111);
P.setFirstname("aaaaaaa");
P.setLastname("dsssss");
P.setId(12);
session.save(P);
session.getTransaction().commit();
}
}
Plz Help Me
I hope to all of
Similar Threads
-
By Irina in forum ASP.NET
Replies: 0
Last Post: 11-29-2002, 10:47 PM
-
Replies: 0
Last Post: 12-13-2001, 12:06 PM
-
By Roseta in forum VB Classic
Replies: 0
Last Post: 11-14-2001, 03:24 AM
-
By Ayman in forum VB Classic
Replies: 0
Last Post: 04-03-2000, 01:08 AM
-
By Jason Bock in forum VB Classic
Replies: 0
Last Post: 03-21-2000, 06:48 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks