Page 2 of 2

Re: Product deleted on restart

Posted: Thu Oct 17, 2013 5:37 pm
by phillipuniverse
This is what I would do:

1. Change the ddl to 'create'. This will create all of the database tables and run the import scripts
2. Shutdown the server (tables will not be dropped)
3. Change the ddl to 'update'

Then you'll be in the state where you've got the initial data import in your database and Hibernate will automatically push entity changes there.

Re: Product deleted on restart

Posted: Fri Oct 18, 2013 10:13 am
by anikanchan
Yeah, that is exactly what I though so ran it with create-update but I guess shutting down the server clears it all. I do still see all the tables in the DB. I think only data are deleted.

Re: Product deleted on restart

Posted: Fri Oct 18, 2013 1:47 pm
by anikanchan
Oh, I see what you are asking me to do. Let me try that out. Thanks.

Re: Product deleted on restart

Posted: Tue Feb 11, 2014 7:08 am
by ackuser
Hi,
I'm running DemoSite on Broad 3.0 with Tomcat and MySql and I find the same problem as Phillip. In fact I changed
blPU.hibernate.hbm2ddl.auto=create-drop to blPU.hibernate.hbm2ddl.auto=update and I found ".... PageNotFound - No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'mycompany'". However when I use blPU.hibernate.hbm2ddl.auto=create-drop I haven't any problems...Someone was able to solve it?

Thanks

Re: Product deleted on restart

Posted: Sun Feb 16, 2014 12:13 am
by Skychan
phillipuniverse wrote:This is what I would do:

1. Change the ddl to 'create'. This will create all of the database tables and run the import scripts
2. Shutdown the server (tables will not be dropped)
3. Change the ddl to 'update'

Then you'll be in the state where you've got the initial data import in your database and Hibernate will automatically push entity changes there.


I performed the above 3 steps; the site/admin functioned but did not retain any DB changes after running Jett-stop and then Jett-start again.

I do not understand why Broadleaf would have the demo in a state where changes are not persisted across server restarts! Any further advice?

Re: Product deleted on restart

Posted: Sun Feb 16, 2014 2:58 am
by Skychan
I figured it out! On this database configuration documentation page:

http://docs.broadleafcommerce.org/core/current/broadleaf-concepts/key-aspects-and-configuration/database-configuration

It explains that
The import_files property instructs hibernate to run the SQL in the list of files that it finds. Broadleaf uses this to populate data needed for the demo and startup applications. Some teams continue to use this early in the development cycle but may choose to disable this and use a more permanent database in later stages.


So I just commented out the lines setting this value:
blPU.hibernate.hbm2ddl.import_files

Also, the file:
/site/src/main/resources/runtime-properties/development.properties
I changed the following from "create-drop" to

blPU.hibernate.hbm2ddl.auto=update

NOW my custmers and products persist server restarts! Only spent a few HOURS trying to achieve expected functionality (since it takes a while to stop-start every time I wanted to test something I hoped would fix it). Wouldn't it make more sense to have a script you would choose to run that would drop all tables, create entire schema, and run SQL to populate DB (when developer realizes something broke)?

Re: Product deleted on restart

Posted: Sun May 04, 2014 3:36 pm
by daniel_locious
ackuser wrote:Hi,
I'm running DemoSite on Broad 3.0 with Tomcat and MySql and I find the same problem as Phillip. In fact I changed
blPU.hibernate.hbm2ddl.auto=create-drop to blPU.hibernate.hbm2ddl.auto=update and I found ".... PageNotFound - No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'mycompany'". However when I use blPU.hibernate.hbm2ddl.auto=create-drop I haven't any problems...Someone was able to solve it?

Thanks



Interesting to find this; I m experiencing the same. Will keep you guys updated for what I find. Meanwhile, anyone has solve this problem? After change hibernate.hbm2ddl.auto to "update" the dispatchersevlet doesn't work any more?!

Re: Product deleted on restart

Posted: Mon May 05, 2014 7:05 am
by daniel_locious
daniel_locious wrote:
ackuser wrote:Hi,
I'm running DemoSite on Broad 3.0 with Tomcat and MySql and I find the same problem as Phillip. In fact I changed
blPU.hibernate.hbm2ddl.auto=create-drop to blPU.hibernate.hbm2ddl.auto=update and I found ".... PageNotFound - No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'mycompany'". However when I use blPU.hibernate.hbm2ddl.auto=create-drop I haven't any problems...Someone was able to solve it?

Thanks



Interesting to find this; I m experiencing the same. Will keep you guys updated for what I find. Meanwhile, anyone has solve this problem? After change hibernate.hbm2ddl.auto to "update" the dispatchersevlet doesn't work any more?!


I found it; for some magic reason, "hibernate.hbm2ddl.auto=update" doesn't work well on broadleaf :lol:

hibernate.hbm2ddl.auto = false will work.

Btw, @phillipuniverse, I might a bit too junior on spring MVC; I couldn't really locate the view resolvers in servlet config xmls. Would you explain a bit, for example, how does the home page '/' map in the view resolver? in which resolver?

Re: Product deleted on restart

Posted: Mon May 05, 2014 12:53 pm
by phillipuniverse
Sure, the '/' is specifically mapped by the Home category:

Code: Select all

INSERT INTO BLC_CATEGORY (CATEGORY_ID,DESCRIPTION,NAME,URL,DEFAULT_PARENT_CATEGORY_ID,ACTIVE_START_DATE, DISPLAY_TEMPLATE) VALUES (2001,'Home','Home','/',2,CURRENT_TIMESTAMP, 'layout/home');


If you run with 'update' then the demo data does not get inserted and thus neither does this BLC_CATEGORY insert. The category URLs are handled by the CategoryHandlerMapping (see also ProductHandlerMapping and PageHandlerMapping) configured in your applicationContext-servlet.xml

Re: Product deleted on restart

Posted: Mon May 05, 2014 3:10 pm
by daniel_locious
aha!

I see; now I understand why my set to false works - because I first set it to "create", thus the data inserted and left there.

Cool cheers, Phillip!