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

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

報錯了,求原因

http://img1.sycdn.imooc.com//56f0f87200012fbc08850445.jpg

我的test.java部分

public class Test {

public static void main(String[] args) {

add();

//findStudentsByGrade();

//update();

//delete();

}

//將學(xué)生添加到班級

public static void add(){

Grade g=new Grade("Java一班", "Java軟件開發(fā)一班");

Student stu1=new Student("張三", "男");

Student stu2=new Student("穆女神", "女");

//如果希望在學(xué)生表中添加對應(yīng)的班級編號,需要在班級中添加學(xué)生,建立關(guān)聯(lián)關(guān)系

/*g.getStudents().add(stu1);

g.getStudents().add(stu2);*/

Session session=HibernateUtil.getSession();

Transaction tx=session.beginTransaction();

session.save(g);

session.save(stu1);

session.save(stu2);

tx.commit();

HibernateUtil.closeSession(session);

}

}


正在回答

3 回答

樓主錯誤解決了么?怎么解決的?

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

配置文件代碼:

<?xml version='1.0' encoding='utf-8'?>

<hibernate-configuration>

? ? ? ?<!-- ? xmlns="http://www.hibernate.org/xsd/hibernate-configuration"

? ? ? ? xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"

? ? ? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">-->

? <session-factory>

? <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

? <property name="connection.driver_class">org.mysql.jdbc.Driver</property>

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

? ? <property name="connection.password">030105</property>

? ? ? ? <property name="connection.url">

? ? ? ? <![CDATA[

? ? ? ? ?jdbc:mysql://localhost:3306/imooc?useUnicode=true&characterEncoding=utf8

? ? ? ? ]]>

? ? ? ? </property>

? ? ? ?<property name="show_sql">true</property>

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

? ? <!-- 指定映射文件路徑 -->

<mapping resource="com/imooc/entity/Grade.hbm.xml"/>

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

? </session-factory>

</hibernate-configuration>


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

根據(jù)報錯信息是你的hibernate.cfg.xml文件有地方寫錯了


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

黑豆0 提問者

配置文件代碼在下面
2016-03-23 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
Hibernate初探之一對多映射
  • 參與學(xué)習(xí)       42160    人
  • 解答問題       310    個

Hibernate中一對多關(guān)聯(lián)映射配置,以及cascade和inverse屬性作用

進(jìn)入課程

報錯了,求原因

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

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

幫助反饋 APP下載

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

公眾號

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