第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

生成表結(jié)構(gòu)還是有錯誤,怎么解決

http://img1.sycdn.imooc.com//584411900001385606560160.jpghttp://img1.sycdn.imooc.com//584411d40001a8b207610221.jpg

SchemaExport方法有一條刪除線,怎么解決

正在回答

3 回答

package?entity;

import?org.hibernate.Session;
import?org.hibernate.SessionFactory;
import?org.hibernate.boot.MetadataSources;
import?org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import?org.hibernate.boot.spi.MetadataImplementor;
import?org.hibernate.cfg.Configuration;
import?org.hibernate.service.ServiceRegistry;
import?org.hibernate.tool.hbm2ddl.SchemaExport;
import?org.junit.Test;

public?class?TestStudents?{
	@Test
	public?void?testSchemaExport(){
		//創(chuàng)建配置對象
		Configuration?config?=?new?Configuration().configure();
		//創(chuàng)建服務(wù)注冊對象
		//ServiceRegistry?serviceRegistry?=?new?StandardServiceRegistryBuilder().applySettings(config.getProperties()).build();
????????ServiceRegistry?serviceRegistry?=?new?StandardServiceRegistryBuilder().configure().build();??
		//創(chuàng)建sessionFactory
		SessionFactory?sessionFactory?=?config.buildSessionFactory(serviceRegistry);
		//創(chuàng)建session對象
		Session?session?=?sessionFactory.getCurrentSession();
		//創(chuàng)建SchemaExport對象
		
		?MetadataImplementor?metadata?=?(MetadataImplementor)?new?MetadataSources(?serviceRegistry?).buildMetadata();??
	????????new?SchemaExport(metadata).create(true,?true);??
	}
	

}

?hibernate 5.0把創(chuàng)建SchemaExport那要跟最下面那個一樣,希望對你有幫助!

0 回復(fù) 有任何疑惑可以回復(fù)我~

換一個HIbernate版本

0 回復(fù) 有任何疑惑可以回復(fù)我~

方法上有一條刪除線,說明這個方法已經(jīng)過時了,不再用了。你這個應(yīng)該是老版本hibernate的方法。我用最新的hibernate只要把SessionFactory創(chuàng)建出來之后,就會自動在數(shù)據(jù)庫中生成對應(yīng)的表。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

生成表結(jié)構(gòu)還是有錯誤,怎么解決

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號