cancel
Showing results for 
Search instead for 
Did you mean: 

I am not able configure hibernate with session bean

Former Member
0 Kudos

Hi

I am not able to configure hibernate with a session bean in NWDS.

I have taken a EJB project,in that i have created a seesion bean.In session bean i have written the following

code

public class SampleSessionBean implements SessionBean {

private SessionContext myContext;

private Session session;

public void ejbRemove() {

}

public void ejbActivate() {

}

public void ejbPassivate() {

}

public void setSessionContext(SessionContext context) {

myContext=context;

this.session=HibernateSessionSingleton.currentSession();

}

/**

  • Business Method.

*/

public String inserData(Date theDate, String strTitle)

{

Configuration cfg=new Configuration().addFile("hibernate.cfg.xml");

Transaction tx=session.beginTransaction();

Sample sa=new Sample();

sa.setDate(theDate);

sa.setTitle(strTitle);

session.save(sa);

tx.commit();

return null;

}

/**

  • Create Method.

*/

public void ejbCreate() throws CreateException {

// TODO : Implement

}

}

I have created hibenate.cfg.xml in EJB root.

It is giving error lik hibernate.cfg.xml in not found.

I am getting the Same code with javaprogram.I am not able to do with Session beans.

thanks and Regards

Satyam

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos