Page 1 of 1

log in problem

Posted: Tue Aug 26, 2014 11:44 pm
by bibroy
I have switched to MYSQL successfully - however I see a problem which was there while I was using HSQLDB.

Problem:
---------------
I have registered a user and then I stop the server (stop-all) and restart the server(jetty-demo) -surprisingly I cannot login with the credentials of the aforementioned user. This happens both with MYSQL and HSQLDB.

Analysis:
----------
I feel that the above problem can happen with HSQLDB since it is an in-memory database - but this should not happen with MYSQL which is a file-system database.

Can you explain this behavior or am I going wrong somewhere.....

Regards,
Bibhash Roy

Re: log in problem

Posted: Tue Aug 26, 2014 11:53 pm
by bibroy
Now may be I am correct - on server startup, the tables are getting recreated.....

Am I correct? If yes, how to avert this table recreation on server startup.....

Bibhash Roy

Re: log in problem

Posted: Wed Aug 27, 2014 12:10 am
by phillipuniverse
Yes, that is right, the tables are getting re-created. This is driven by the blPU.hibernate.hbm2ddl.auto property. This is set to 'create-drop' in development-shared.properties (which will run the SQL import files that are also in that file). What you can do instead is change this value to 'create', start up the application (which will run all the SQL imports) then change that value to 'update' and go from there. Then the system won't delete and recreate all of your tables on a restart, but if you add a column then that will be reflected.

Re: log in problem

Posted: Wed Aug 27, 2014 12:42 am
by bibroy
One clarification required - why do I need to change to "create" and then to "update" the property value - can't I change to "update" directly from "create-drop" and then start the server..


Bibhash Roy

Re: log in problem

Posted: Wed Aug 27, 2014 12:45 am
by bibroy
I mean - are the tables dropped on server shutdown - that does not seem likely..

Re: log in problem

Posted: Wed Aug 27, 2014 1:47 am
by phillipuniverse
create-drop will completely wipe out all data when the server shuts down (hence the 'drop' at the end). The actual operations that take place with the different ddl values:

create-drop
1. Server starts up
2. Drop all of the data in the database of all the tables that hibernate knows about
3. Create all of the Hibernate tables from scratch
4. Run the import scripts
--- application runs ---
5. Shut down server
6. All data and all tables in the database are dropped
---- end ----

create
1. Server starts up
2. Drop all of the data in the database of all the tables that hibernate knows about
3. Create all of the Hibernate tables from scratch
4. Run the import scripts
--- application runs ---
5. Shut down server
--- end ----

update
1. Server starts up
2. Existing columns are untouched
3. If there are new columns, Hibernate creates them (Data is untouched and preserved)
--- application runs ---
5. Shut down server
--- end ----

validate
1. Server starts up
2. If the schema does not match the Hibernate entities, the server immediately dies
--- application runs ---
5. Shut down server
--- end ----

none
1. Server starts up
--- application runs ---
5. Shut down server
--- end ----

Re: log in problem

Posted: Wed Aug 27, 2014 1:52 am
by bibroy
That's a fantastic answer and it clarifies the whole thing! Thanks a lot!

Bibhash Roy