jeudi 26 mars 2015

Spring4 hibernate4 integration hbm2ddl.auto not rendered

I am integrating spring and hibernate.


Here is project structure:


enter image description here


this is applicationContext.xml:



<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:aop="http://ift.tt/OpNdV1"
xmlns:c="http://ift.tt/MffYna"
xmlns:context="http://ift.tt/GArMu7"
xmlns:flow="http://ift.tt/19rsrif"
xmlns:jee="http://ift.tt/OpNaZ5"
xmlns:jms="http://ift.tt/1iMF6wC"
xmlns:lang="http://ift.tt/OGfeTY"
xmlns:osgi="http://ift.tt/1apCv6f"
xmlns:p="http://ift.tt/1jdM0fE"
xmlns:tx="http://ift.tt/OGfeU2"
xmlns:util="http://ift.tt/OGfeTW"

xsi:schemaLocation="http://ift.tt/GArMu6
http://ift.tt/18sW2ax
http://ift.tt/OpNdV1
http://ift.tt/JvbN5c
http://ift.tt/GArMu7
http://ift.tt/1bGeTcI
http://ift.tt/19rsrif
http://ift.tt/1iMF6wL
http://ift.tt/OpNaZ5
http://ift.tt/JvbN5h
http://ift.tt/1iMF6wC
http://ift.tt/1Fj1J6D
http://ift.tt/OGfeTY
http://ift.tt/1pFdnVn
http://ift.tt/1apCv6f
http://ift.tt/VRFjZG
http://ift.tt/OGfeU2
http://ift.tt/1cKeJ93
http://ift.tt/OGfeTW
http://ift.tt/1aj0W5e">


<!-- Activates scanning of @Autowired -->
<context:annotation-config/>

<!-- Activates scanning of @Repository and @Service -->
<context:component-scan base-package="com.sajjad.dao , com.sajjad.service"/>

<!-- Configure JDBC Connection-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/obs" />
<property name="username" value="root" />
<property name="password" value="2323" />
</bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
p:dataSource-ref="dataSource"
p:packagesToScan="com.sajjad.dao"
p:hibernateProperties-ref="hibernateProperties"/>

<util:properties id="hibernateProperties">
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.show_sql">true</prop>
</util:properties>

<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- Detect @Transactional Annotation -->
<tx:annotation-driven transaction-manager="transactionManager" />

</beans>


And here is Books pojo:



@Entity
@Table(name = "books")
public class Books implements Serializable {

@Id
@GeneratedValue
private Integer id;
@Column(nullable = false)
private String title;
//other methods
}


But hibernate can't create table with name books in database obs.


database obs is present.


Aucun commentaire:

Enregistrer un commentaire