Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Spring
Hibernate : Empty Table recreated when spring starts
Frank VanOor
Ranch Hand
Posts: 49
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Each time I'm starting Tomcat/Spring, hibernate recreates the mapped table (only one table is mapped).
Below the applicationcontext and the Entity Class.
Many thanks in advance.
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> <context:component-scan base-package="com.stockdomain"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <!-- dataSource --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>org.postgresql.Driver</value></property> <property name="url"><value>jdbc:postgresql://localhost/db_finance</value></property> <property name="username"><value>xxxx</value></property> <property name="password"><value>xxxx</value></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- <property name="packagesToScan" value="com.stockdomain.domain" />--> <property name="annotatedClasses"> <list> <value>com.stockdomain.domain.Stock</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> </props> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!-- Enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="txManager"/> </beans>
package com.stockdomain.domain; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "stock") public class Stock { @Id @GeneratedValue private int id; @Column private String code; @Column private String name; @Column private String isin; @Column private String exchangeCode; @Column private String countryCode; @Column private String subSectorCode; @Column private String active; @Column private String liquid; public void setId(int id) { this.id = id; } public int getId() { return id; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getIsin() { return isin; } public void setIsin(String isin) { this.isin = isin; } public String getExchangeCode() { return exchangeCode; } public void setExchangeCode(String exchangeCode) { this.exchangeCode = exchangeCode; } public String getCountryCode() { return countryCode; } public void setCountryCode(String countryCode) { this.countryCode = countryCode; } public String getSubSectorCode() { return subSectorCode; } public void setSubSectorCode(String subSectorCode) { this.subSectorCode = subSectorCode; } public String getActive() { return active; } public void setActive(String active) { this.active = active; } public String getLiquid() { return liquid; } public void setLiquid(String liquid) { this.liquid = liquid; } }
Paul Clapham
Marshal
Posts: 28177
95
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Isn't that a Hibernate FAQ? Anyway it does that because you tell it to do so in line 42 of what you posted.
Mark Spritzler
ranger
Posts: 17347
11
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This 42
<prop key="hibernate.hbm2ddl.auto">create</prop>
Mark
Perfect World Programming, LLC
-
iOS Apps
How to Ask Questions the Smart Way FAQ
Frank VanOor
Ranch Hand
Posts: 49
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I removed this property, and all works fine now.
Many thanks !!!
Frank
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
HibernateException: No Hibernate Session bound to thread
Spring 2.5 - Rolling back first method, when the second method throws Runtime ex
org.hibernate.MappingException: Unknown entity
org.hibernate.MappingException: Unknown entity:
data not persisted using hibernate spring integration
More...