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

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

myEclipse中如何配置Hibernate配置文件?

myEclipse如何配置Hibernate配置文件?

正在回答

1 回答

在項目的src下新建一個.xml 名稱為hibernate.cfg.xml?

代碼如下(我的是mysql+hibernate5.3)版本不同 寫法都不同 看看你用的都是啥版本

注:其中我的數(shù)據(jù)庫是hibernate 賬號root 密碼為空 你要改成你自己的

<mapping resource="com/student/Student.hbm.xml"/> 粗體部分寫你自己的實體類的映射文件地址


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

? ? <session-factory>

? ? <!-- 第一部分: 配置數(shù)據(jù)庫信息 必須的 -->

<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>

<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?useSSL=false&amp;serverTimezone=UTC</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password"></property>

<!-- 第二部分: 配置hibernate信息? 可選的-->

<!-- 輸出底層sql語句 -->

<property name="hibernate.show_sql">true</property>

<!-- 輸出底層sql語句格式 -->

<property name="hibernate.format_sql">true</property>

<!-- hibernate幫創(chuàng)建表,需要配置之后?

update: 如果已經(jīng)有表,更新,如果沒有,創(chuàng)建

-->

<property name="hibernate.hbm2ddl.auto">update</property>

<!-- 配置數(shù)據(jù)庫方言

在mysql里面實現(xiàn)分頁 關(guān)鍵字 limit,只能使用mysql里面

在oracle數(shù)據(jù)庫,實現(xiàn)分頁rownum

讓hibernate框架識別不同數(shù)據(jù)庫的自己特有的語句

-->

<property name="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</property>

<property name="hibernate.current_session_context_class">thread</property>

<!-- 第三部分: 把映射文件放到核心配置文件中 必須的-->

<mapping resource="com/student/Student.hbm.xml"/>

? ? </session-factory>

</hibernate-configuration>


2 回復(fù) 有任何疑惑可以回復(fù)我~
#1

艾米麗宏 提問者

太詳細了,非常感謝!
2018-07-20 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

myEclipse中如何配置Hibernate配置文件?

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

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

幫助反饋 APP下載

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

公眾號

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