A robust starter web application to ease Java webapp development.

Home | Tutorials | Demos | Issues

Always create new database

View: New views
6 Messages — Rating Filter:   Alert me  

Always create new database

by Vu Pham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I have created an example like "myusers". How can I disable the function that always create new database when restart that application?. I deleted following statement , but couldn't disable it.

<property name="hibernateProperties">
        <props>
                <prop key="hibernate.dialect">
                        net.sf.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
</property>

Re: Always create new database

by Matt Raible-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Removing <prop key="hibernate.hbm2ddl.auto">update</prop> will prevent
HIbernate from recreating (or updating) tables.  If you're using MySQL
- there's a setting in jdbc.properties that says "create the database
if it doesn't exist.

Matt

On 2/15/07, Vu Pham <vukhi2002@...> wrote:

>
> Hi all,
>
> I have created an example like "myusers". How can I disable the function
> that always create new database when restart that application?. I deleted
> following statement , but couldn't disable it.
>
> <property name="hibernateProperties">
>         <props>
>                 <prop key="hibernate.dialect">
>                         net.sf.hibernate.dialect.MySQLDialect
>                 </prop>
>                 <prop key="hibernate.hbm2ddl.auto">update</prop>
>         </props>
> </property>
> --
> View this message in context: http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8986347
> Sent from the Equinox Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Always create new database

by Vu Pham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Matt for your reply.
I have already deleted the line "<prop key="hibernate.hbm2ddl.auto">update</prop>" , but it still create/update the database.

And I cann't find the file "jdbc.properties" ... I'm using equinox-1.0.


Matt Raible-3 wrote:
Removing <prop key="hibernate.hbm2ddl.auto">update</prop> will prevent
HIbernate from recreating (or updating) tables.  If you're using MySQL
- there's a setting in jdbc.properties that says "create the database
if it doesn't exist.

Matt

On 2/15/07, Vu Pham <vukhi2002@yahoo.com> wrote:
>
> Hi all,
>
> I have created an example like "myusers". How can I disable the function
> that always create new database when restart that application?. I deleted
> following statement , but couldn't disable it.
>
> <property name="hibernateProperties">
>         <props>
>                 <prop key="hibernate.dialect">
>                         net.sf.hibernate.dialect.MySQLDialect
>                 </prop>
>                 <prop key="hibernate.hbm2ddl.auto">update</prop>
>         </props>
> </property>
> --
> View this message in context: http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8986347
> Sent from the Equinox Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@equinox.dev.java.net
> For additional commands, e-mail: users-help@equinox.dev.java.net
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@equinox.dev.java.net
For additional commands, e-mail: users-help@equinox.dev.java.net

Re: Always create new database

by Matt Raible-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you're using Equinox 1.0 - does that mean you're using HSQL for
your database as well?  What's the "create database" problem you're
experiencing?

Matt

On 2/15/07, Vu Pham <vukhi2002@...> wrote:

>
> Thanks Matt for your reply.
> I have already deleted the line "<prop
> key="hibernate.hbm2ddl.auto">update</prop>" , but it still create/update the
> database.
>
> And I cann't find the file "jdbc.properties" ... I'm using equinox-1.0.
>
>
>
> Matt Raible-3 wrote:
> >
> > Removing <prop key="hibernate.hbm2ddl.auto">update</prop> will prevent
> > HIbernate from recreating (or updating) tables.  If you're using MySQL
> > - there's a setting in jdbc.properties that says "create the database
> > if it doesn't exist.
> >
> > Matt
> >
> > On 2/15/07, Vu Pham <vukhi2002@...> wrote:
> >>
> >> Hi all,
> >>
> >> I have created an example like "myusers". How can I disable the function
> >> that always create new database when restart that application?. I deleted
> >> following statement , but couldn't disable it.
> >>
> >> <property name="hibernateProperties">
> >>         <props>
> >>                 <prop key="hibernate.dialect">
> >>                         net.sf.hibernate.dialect.MySQLDialect
> >>                 </prop>
> >>                 <prop key="hibernate.hbm2ddl.auto">update</prop>
> >>         </props>
> >> </property>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8986347
> >> Sent from the Equinox Users mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> For additional commands, e-mail: users-help@...
> >>
> >>
> >
> >
> > --
> > http://raibledesigns.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8997909
> Sent from the Equinox Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Always create new database

by Vu Pham :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have replaced MySQL with HSQL. Once I restarted Tomcat , then ran my application , it would create database again (So I lost all my data that be inserted). Here is my applicationContext.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
        <bean id="dataSource"
                class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                <property name="driverClassName">
                        <value>com.mysql.jdbc.Driver</value>
                </property>
                <property name="url">
                        <value>jdbc:mysql://localhost/appfuse</value>
                </property>
                <property name="username">
                        <value>root</value>
                </property>
                <property name="password">
                        <value></value>
                </property>
        </bean>

        <!-- Hibernate SessionFactory -->
        <bean id="sessionFactory"
                class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
                <property name="dataSource">
                        <ref local="dataSource" />
                </property>
                <property name="mappingResources">
                        <list>
                                <!-- Add list of .hbm.xml files here -->
                                <value>org/appfuse/model/User.hbm.xml</value>
                        </list>
                </property>
                <property name="hibernateProperties">
                        <props>
                                <prop key="hibernate.dialect">
                                        net.sf.hibernate.dialect.MySQLDialect
                                </prop>
                        </props>
                </property>
        </bean>

        <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
        <bean id="transactionManager"
                class="org.springframework.orm.hibernate.HibernateTransactionManager">
                <property name="sessionFactory">
                        <ref local="sessionFactory" />
                </property>
        </bean>

        <!-- Add DAOs here -->
        <bean id="userDAO"
                class="org.appfuse.dao.hibernate.UserDAOHibernate">
                <property name="sessionFactory">
                        <ref local="sessionFactory" />
                </property>
        </bean>

        <!-- Add Managers here -->
        <bean id="userManager"
                class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
                <property name="transactionManager">
                        <ref local="transactionManager" />
                </property>
                <property name="target">
                        <ref local="userManagerTarget" />
                </property>
                <property name="transactionAttributes">
                        <props>
                                <prop key="save*">PROPAGATION_REQUIRED</prop>
                                <prop key="remove*">PROPAGATION_REQUIRED</prop>
                                <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
                        </props>
                </property>
        </bean>
        <bean id="userManagerTarget"
                class="org.appfuse.service.impl.UserManagerImpl">
                <property name="userDAO">
                        <ref local="userDAO" />
                </property>
        </bean>
</beans>


Matt Raible-3 wrote:
If you're using Equinox 1.0 - does that mean you're using HSQL for
your database as well?  What's the "create database" problem you're
experiencing?

Matt

On 2/15/07, Vu Pham <vukhi2002@yahoo.com> wrote:
>
> Thanks Matt for your reply.
> I have already deleted the line "<prop
> key="hibernate.hbm2ddl.auto">update</prop>" , but it still create/update the
> database.
>
> And I cann't find the file "jdbc.properties" ... I'm using equinox-1.0.
>
>
>
> Matt Raible-3 wrote:
> >
> > Removing <prop key="hibernate.hbm2ddl.auto">update</prop> will prevent
> > HIbernate from recreating (or updating) tables.  If you're using MySQL
> > - there's a setting in jdbc.properties that says "create the database
> > if it doesn't exist.
> >
> > Matt
> >
> > On 2/15/07, Vu Pham <vukhi2002@yahoo.com> wrote:
> >>
> >> Hi all,
> >>
> >> I have created an example like "myusers". How can I disable the function
> >> that always create new database when restart that application?. I deleted
> >> following statement , but couldn't disable it.
> >>
> >> <property name="hibernateProperties">
> >>         <props>
> >>                 <prop key="hibernate.dialect">
> >>                         net.sf.hibernate.dialect.MySQLDialect
> >>                 </prop>
> >>                 <prop key="hibernate.hbm2ddl.auto">update</prop>
> >>         </props>
> >> </property>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8986347
> >> Sent from the Equinox Users mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@equinox.dev.java.net
> >> For additional commands, e-mail: users-help@equinox.dev.java.net
> >>
> >>
> >
> >
> > --
> > http://raibledesigns.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@equinox.dev.java.net
> > For additional commands, e-mail: users-help@equinox.dev.java.net
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8997909
> Sent from the Equinox Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@equinox.dev.java.net
> For additional commands, e-mail: users-help@equinox.dev.java.net
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@equinox.dev.java.net
For additional commands, e-mail: users-help@equinox.dev.java.net

Re: Always create new database

by Matt Raible-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

AFAIK, there's nothing in this configuration that would cause this
behavior. You might want to make sure you don't have a
hibernate.properties somewhere on your classpath.

Matt

On 2/16/07, Vu Pham <vukhi2002@...> wrote:

>
> I have replaced MySQL with HSQL. Once I restarted Tomcat , then ran my
> application , it would create database again (So I lost all my data that be
> inserted). Here is my applicationContext.xml :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
>     "http://www.springframework.org/dtd/spring-beans.dtd">
>
> <beans>
>         <bean id="dataSource"
>                 class="org.springframework.jdbc.datasource.DriverManagerDataSource">
>                 <property name="driverClassName">
>                         <value>com.mysql.jdbc.Driver</value>
>                 </property>
>                 <property name="url">
>                         <value>jdbc:mysql://localhost/appfuse</value>
>                 </property>
>                 <property name="username">
>                         <value>root</value>
>                 </property>
>                 <property name="password">
>                         <value></value>
>                 </property>
>         </bean>
>
>         <!-- Hibernate SessionFactory -->
>         <bean id="sessionFactory"
>                 class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
>                 <property name="dataSource">
>                         <ref local="dataSource" />
>                 </property>
>                 <property name="mappingResources">
>                         <list>
>                                 <!-- Add list of .hbm.xml files here -->
>                                 <value>org/appfuse/model/User.hbm.xml</value>
>                         </list>
>                 </property>
>                 <property name="hibernateProperties">
>                         <props>
>                                 <prop key="hibernate.dialect">
>                                         net.sf.hibernate.dialect.MySQLDialect
>                                 </prop>
>                         </props>
>                 </property>
>         </bean>
>
>         <!-- Transaction manager for a single Hibernate SessionFactory (alternative
> to JTA) -->
>         <bean id="transactionManager"
>                 class="org.springframework.orm.hibernate.HibernateTransactionManager">
>                 <property name="sessionFactory">
>                         <ref local="sessionFactory" />
>                 </property>
>         </bean>
>
>         <!-- Add DAOs here -->
>         <bean id="userDAO"
>                 class="org.appfuse.dao.hibernate.UserDAOHibernate">
>                 <property name="sessionFactory">
>                         <ref local="sessionFactory" />
>                 </property>
>         </bean>
>
>         <!-- Add Managers here -->
>         <bean id="userManager"
>
> class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>                 <property name="transactionManager">
>                         <ref local="transactionManager" />
>                 </property>
>                 <property name="target">
>                         <ref local="userManagerTarget" />
>                 </property>
>                 <property name="transactionAttributes">
>                         <props>
>                                 <prop key="save*">PROPAGATION_REQUIRED</prop>
>                                 <prop key="remove*">PROPAGATION_REQUIRED</prop>
>                                 <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
>                         </props>
>                 </property>
>         </bean>
>         <bean id="userManagerTarget"
>                 class="org.appfuse.service.impl.UserManagerImpl">
>                 <property name="userDAO">
>                         <ref local="userDAO" />
>                 </property>
>         </bean>
> </beans>
>
>
>
> Matt Raible-3 wrote:
> >
> > If you're using Equinox 1.0 - does that mean you're using HSQL for
> > your database as well?  What's the "create database" problem you're
> > experiencing?
> >
> > Matt
> >
> > On 2/15/07, Vu Pham <vukhi2002@...> wrote:
> >>
> >> Thanks Matt for your reply.
> >> I have already deleted the line "<prop
> >> key="hibernate.hbm2ddl.auto">update</prop>" , but it still create/update
> >> the
> >> database.
> >>
> >> And I cann't find the file "jdbc.properties" ... I'm using equinox-1.0.
> >>
> >>
> >>
> >> Matt Raible-3 wrote:
> >> >
> >> > Removing <prop key="hibernate.hbm2ddl.auto">update</prop> will prevent
> >> > HIbernate from recreating (or updating) tables.  If you're using MySQL
> >> > - there's a setting in jdbc.properties that says "create the database
> >> > if it doesn't exist.
> >> >
> >> > Matt
> >> >
> >> > On 2/15/07, Vu Pham <vukhi2002@...> wrote:
> >> >>
> >> >> Hi all,
> >> >>
> >> >> I have created an example like "myusers". How can I disable the
> >> function
> >> >> that always create new database when restart that application?. I
> >> deleted
> >> >> following statement , but couldn't disable it.
> >> >>
> >> >> <property name="hibernateProperties">
> >> >>         <props>
> >> >>                 <prop key="hibernate.dialect">
> >> >>                         net.sf.hibernate.dialect.MySQLDialect
> >> >>                 </prop>
> >> >>                 <prop key="hibernate.hbm2ddl.auto">update</prop>
> >> >>         </props>
> >> >> </property>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8986347
> >> >> Sent from the Equinox Users mailing list archive at Nabble.com.
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> >> For additional commands, e-mail: users-help@...
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > http://raibledesigns.com
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@...
> >> > For additional commands, e-mail: users-help@...
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8997909
> >> Sent from the Equinox Users mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> For additional commands, e-mail: users-help@...
> >>
> >>
> >
> >
> > --
> > http://raibledesigns.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Always-create-new-database-tf3234063s2369.html#a8999792
> Sent from the Equinox Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


--
http://raibledesigns.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

LightInTheBox - Buy quality products at wholesale price!