Hi,
I solved this problem by adding hibernate.properties file to my src folder and by changing names of Event.cfg.xml and Event.hbm.xml to hibernate.cfg.xml and hibernate.hbm.xml.Now it's working fine now.
But
now i have some problem with logic of my code.I am placing my client programs here please check these once.
package client;
import org.hibernate.*;
import org.hibernate.cfg.Configuration;
import events.*;
public class TestClient
{
public Event buildEvent()
{
Event event = new Event();
event.setEventTitle("Environmental Meet");
event.setTotalMembers(100);
return event;
}
public Session openSession()
{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session =sessionFactory.openSession();
return session;
}
public Event testSaveEvent(EventManager manager)
{
Event event = buildEvent();
manager.saveEvent(event);
System.out.println("Event saved with ID = "+event.getEventId());
return event;
}
public static void main(String[] args)
{
TestClient client = new TestClient();
Session session = client.openSession();
EventManager manager = new EventManager(session);
Event event = client.testSaveEvent(manager);
System.out.println("End of Program");
session.flush();
}
}
and
package client;
import org.hibernate.Session;
import events.Event;
public class EventManager
{
private Session session = null;
public EventManager(Session session)
{
if(session == null)
throw new RuntimeException("Invalid session object. Cannot instantiate the EventManager.");
this.session = session;
}
public void saveEvent(Event event)
{
session.save(event);
}
}
Now my problem is...
1. when i try to save a row by using these classes,all those previous values(entered from Oracle) are getting deleted.Now my table is having only one row which is entered through this classes.
2. After this i changed entry values for that table fields in my class and now i run this client program once again.Now my previously entered row in step1 was deleted and now my table contains new row only.
At any time i am getting only one row in my table.But i want to save all those rows in my table.
What is wrong with my code.Can any one please help me..
Thank q very much,
sireesha.