Java – hibernate does not create tables – spring MVC
                                        
                    •
                    Java                                    
                I have a spring project and I'm using hibernation When I started the project, DB didn't change
I tried the difrenf configuration, but it didn't work
What idea may be wrong?
Hibernate in servlet Configuration in XML:
<beans:beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
         xmlns:beans="http://www.springframework.org/schema/beans">
<context:component-scan base-package="com.springapp.mvc"/>
<!--Data source has the database information -->
<beans:bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <beans:property name="driverClassName" value="org.postgresql.Driver"/>
    <beans:property name="url" value="jdbc:postgresql://localhost:5432/Praktyki"/>
    <beans:property name="username" value="dbusersolsoft"/>
    <beans:property name="password" value="dbpassSolsoft"/>
</beans:bean>
<!-- Session Factory -->
<beans:bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSession@R_502_764@">
    <beans:property name="dataSource" ref="dataSource"/>
    <beans:property name="packagesToScan">
            <value>com.springapp.mvc.model</value>
    </beans:property>
    <!--<beans:property name="showsql" value="true" />-->
    <!--<beans:property name="generateDdl" value="true" />-->
    <beans:property name="hibernateProperties">
        <beans:props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HsqlDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">false</prop>
        </beans:props>
    </beans:property>
</beans:bean>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
Solution
use
<prop key="hibernate.hbm2ddl.auto">create</prop>
According to the document, update updates the existing schema
Link for reference
In short,
validate: validate the schema,makes no changes to the database. update: update the schema. create: creates the schema,destroying prevIoUs data. create-drop: drop the schema at the end of the session. auto : Automatically validates or exports schema DDL to the database when the SessionFactory is created
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        