The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

logical_way (2) [Avatar] Offline
I am testing Hibernate one sunday and my whole sunday got wasted. i was making a simple application with POJO style architecture. I am using WebSphere 5.0 Application Developer and using it's own inbuild JNDI Context and used Struts 1.1 framework. And also used class as given in book. The only trick is made an interface responsible for only two methods presently [load and save of my model.]. Then I made two tables in MySql 4.0 using mysql-connector-3.0.8-stable-bin.jar jdbc driver one hold user information and other address, there is one to one mapping between both with loginid primary key in user and foreign key in address table. And used following mapping

For User:
<one-to-one name="address" class="Address" cascade="save-update"/>

For Address:
<one-to-one name="user" class="User" constrained="true"/>

and provided getter/setter for both classes in both classes.

Then I made UserDAO extending from GenericDAO[with load and save methods] having other user related bussiness logic.

Then I have Factory pattern called BaseDAOFactory that returns implementation of GenericDAO interface.

Code snippet is as follows:
public class BaseDAOFactory{


public static GenericDAO getDAOInstance(String type){
return new UserDAOImpl();

Since user is implementing USERDAO that extends GenericDAO so it should work.

Now in action class I called this implementation in addUser method made in my action called UserManagementAction extending Struts DispatchAction Class
as follows:

public ActionForward addUser(...arguments....){
UserForm user = (UserForm) form;
User u = user.getUser();//returns set data from request
//encapsulated in User model associated in mapping resource.
UserDAOImpl impl = (UserDAOImpl) BaseDAOFactory.getDAOInstance("user");;


Now, the much waited UserDAOImpl class it is using as given in the book to load and save objects obtaining session using threadlocal pattern etc.

public class UserDAOImpl implements UserDAO{

public UserDAOImpl(){

public void save(User user) throws DataException{
Session s = HibernateUtil.openSession();;


Alas,but this is not working when ever i try to save it gives no error but my server stops also there is Window's VC++ debugger pops up asking for debugging or exiting the application resulting ins howing me all the machine language code of JVM. I am using Windows 2K pro.

Can u tell me what's the problem as soon as possible pls.
My email id is We are planning to use Hibernate in our project and I am testing it checking its feasability and scalability also efficiency. i am quite impressed by its simplicity especially the way ti is handling all the mappings its superb. Keep it up. Thanks in advance.