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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Test報(bào)錯(cuò),無法測試 報(bào)錯(cuò)如下

2016-11-26 10:54:02 org.hibernate.annotations.common.Version <clinit>

INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}

2016-11-26 10:54:02 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {4.2.4.Final}

2016-11-26 10:54:02 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

2016-11-26 10:54:02 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist

2016-11-26 10:54:02 org.hibernate.cfg.Configuration configure

INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml

2016-11-26 10:54:02 org.hibernate.cfg.Configuration getConfigurationInputStream

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml

2016-11-26 10:54:02 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: com/hhu/factory/Student.hbm.xml


代碼如下


import java.util.Date;


import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.Transaction;

import org.hibernate.cfg.Configuration;

import org.hibernate.service.ServiceRegistry;

import org.hibernate.service.ServiceRegistryBuilder;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;


import com.hhu.factory.Student;


public class StudentTest {

private SessionFactory sessionFactory;

private Session session;

private Transaction transaction;

@Test

public void TestStudent(){

Student student = new Student(1,"洪七公","男",new Date(),"丐幫");

session.save(student);//保存對(duì)象進(jìn)入數(shù)據(jù)庫

}

@Before

public void init(){

//創(chuàng)建配置對(duì)象

Configuration config = new Configuration().configure();

//創(chuàng)建服務(wù)注冊對(duì)象

ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();

//創(chuàng)建會(huì)話工廠對(duì)象

sessionFactory = config.buildSessionFactory(serviceRegistry);

//打開會(huì)話

session = sessionFactory.openSession();

//打開事務(wù)

transaction = session.beginTransaction();

}

@After

public void destory(){

//提交事務(wù);

transaction.commit();

//關(guān)閉會(huì)話;

session.close();

//關(guān)閉會(huì)話工廠;

sessionFactory.close();

}

}

下面是我的 student.hbm.xml文檔

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

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

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

<!--?

? ? Mapping file autogenerated by MyEclipse Persistence Tools

-->

<hibernate-mapping>

? ? <class name="com.hhu.factory.Student" table="STUDENT" catalog="mydata">

? ? ? ? <id name="sid" type="java.lang.Integer">

? ? ? ? ? ? <column name="SID" />

? ? ? ? ? ? <generator class="native" />

? ? ? ? </id>

? ? ? ? <property name="sname" type="java.lang.String">

? ? ? ? ? ? <column name="SNAME" />

? ? ? ? </property>

? ? ? ? <property name="gender" type="java.lang.String">

? ? ? ? ? ? <column name="GENDER" />

? ? ? ? </property>

? ? ? ? <property name="birthday" type="java.util.Date">

? ? ? ? ? ? <column name="BIRTHDAY" length="10" />

? ? ? ? </property>

? ? ? ? <property name="address" type="java.lang.String">

? ? ? ? ? ? <column name="ADDRESS" />

? ? ? ? </property>

? ? </class>

</hibernate-mapping>


正在回答

4 回答

Students.hbm.xml有放到src文件夾下了嗎?

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

+1我也遇到這個(gè)問題了



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

<?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">

<!-- Generated by MyEclipse Hibernate Tools. ? ? ? ? ? ? ? ? ? -->

<hibernate-configuration>


<session-factory>

<property name="dialect">

org.hibernate.dialect.MySQLDialect

</property>

<property name="connection.url">jdbc:mysql:///mydata</property>

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

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

<property name="connection.driver_class">

com.mysql.jdbc.Driver

</property>

<property name="myeclipse.connection.profile">

com.mysql.jdbc.Driver

</property>


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

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

<property name="hbm2ddl.auto">create</property>

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


</session-factory>


</hibernate-configuration>

這個(gè)是我的配置文檔,前輩看看呢

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

/hibernate.cfg.xml 文件怎么配置的?

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

舉報(bào)

0/150
提交
取消

Test報(bào)錯(cuò),無法測試 報(bào)錯(cuò)如下

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

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

幫助反饋 APP下載

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

公眾號(hào)

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