浏览 6013 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2007-04-30
程序添删改查都没问题,列表数据也没问题,只是一启动服务器就会清空表中的数据。 请问这是怎么回事? 这是pojo类: package com.game.products.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.GenericGenerator; @Entity @Table(name="products") public class Products { // Fields @Id @GeneratedValue(generator = "c-assigned") @GenericGenerator(name = "c-assigned", strategy = "assigned") @Column(name="game_id") private String gameId;//编号 @Column(name="game_name_cn") private String gameNameCn;//中文名称 @Column(name="game_name_en") private String gameNameEn;//英文名称 @Column(name="game_capacity") private String gameCapacity;//碟数 @Column(name="game_version") private String gameVersion;//版本 @Column(name="game_media") private String gameMedia;//介质 @Column(name="game_copyright") private String gameCopyright;//版权 @Column(name="game_price") private String gamePrice;//价格 @Column(name="game_content") private String gameContent;//攻略 // Constructors public Products(){} // Property accessors public String getGameCapacity() { return gameCapacity; } public void setGameCapacity(String gameCapacity) { this.gameCapacity = gameCapacity; } public String getGameId() { return gameId; } public void setGameId(String gameId) { this.gameId = gameId; } public String getGameNameCn() { return gameNameCn; } public void setGameNameCn(String gameNameCn) { this.gameNameCn = gameNameCn; } public String getGameNameEn() { return gameNameEn; } public void setGameNameEn(String gameNameEn) { this.gameNameEn = gameNameEn; } public String getGameVersion() { return gameVersion; } public void setGameVersion(String gameVersion) { this.gameVersion = gameVersion; } public String getGameMedia() { return gameMedia; } public void setGameMedia(String gameMedia) { this.gameMedia = gameMedia; } public String getGameCopyright() { return gameCopyright; } public void setGameCopyright(String gameCopyright) { this.gameCopyright = gameCopyright; } public String getGameContent() { return gameContent; } public void setGameContent(String gameContent) { this.gameContent = gameContent; } public String getGamePrice() { return gamePrice; } public void setGamePrice(String gamePrice) { this.gamePrice = gamePrice; } } 这是applicationContext.xml中的session配置: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> </props> </property> <property name="annotatedClasses"> <list> <value>com.game.products.model.Products</value> </list> </property> </bean> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-04-30
<prop key="hibernate.hbm2ddl.auto">create</prop>
create改为update或者none |
|
返回顶楼 | |
发表时间:2007-04-30
问题就是这一句了
引用 <prop key="hibernate.hbm2ddl.auto">create</prop>
每一次重启,加载Hibernate配置文件后,都是重新生成一次数据库的schema。去掉就可以了。或改成update。 |
|
返回顶楼 | |
发表时间:2007-04-30
<prop key="hibernate.hbm2ddl.auto">create</prop>
|
|
返回顶楼 | |
发表时间:2007-04-30
这跟hibernate annotaction 没有关系
|
|
返回顶楼 | |
发表时间:2007-05-04
谢谢大家,问题解决了。
|
|
返回顶楼 | |