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

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

為什么我調(diào)試的代碼出錯(cuò) 提示 Session session = MyHibernateSessionFactory.getSessionFactory().getCurrentSession();出錯(cuò)

package db;


import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;

import org.hibernate.service.ServiceRegistry;

import org.hibernate.service.ServiceRegistryBuilder;


public class MyHibernateSessionFactory {

/**

* 會(huì)話工廠屬性

*/

private static SessionFactory sessionFactory;

/**

* 構(gòu)造方法私有化,保證單例模式

*/

private MyHibernateSessionFactory(){

}


/**

* 公有的方法,獲取會(huì)話工廠對(duì)象

* @author huangguoce

* @return sessionFactory?

*/

public static ?SessionFactory getSessionFactory(){

if (sessionFactory == null) {

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

ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()

.applySettings(configuration.getProperties())

.buildServiceRegistry();

sessionFactory =configuration.buildSessionFactory(serviceRegistry);

return sessionFactory;

}else {

return sessionFactory;

}

}

}



package service;


import java.util.List;


import org.hibernate.Query;

import org.hibernate.Session;

import org.hibernate.Transaction;


import db.MyHibernateSessionFactory;

import entity.User;


public class UserDaoImpl implements UserDao{


@Override

public boolean userLogin(User user) {

/**

* 事務(wù)對(duì)象

*/

Transaction tx = null;

String sql = "";


try {

Session session = MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

//開啟事務(wù)

tx = session.beginTransaction();

sql = "from user where username=? and password=?";

Query query = session.createQuery(sql);

query.setParameter(0, user.getUsername());

query.setParameter(1, user.getPassword());

List userList = query.list();

System.out.println(userList.toString());

tx.commit();

if (userList.size()>0) {

return true;

}else {

return false;

}

} catch (Exception e) {

e.printStackTrace();

return false;

}finally{

if (tx != null) {

tx = null;

}

}

}


}



五月 09, 2016 8:39:13 下午 org.hibernate.annotations.common.Version <clinit>

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

五月 09, 2016 8:39:13 下午 org.hibernate.Version logVersion

INFO: HHH000412: Hibernate Core {4.2.2.Final}

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Environment <clinit>

INFO: HHH000206: hibernate.properties not found

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Configuration configure

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

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Configuration getConfigurationInputStream

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

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: entity/Student.hbm.xml

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Configuration addResource

INFO: HHH000221: Reading mappings from resource: entity/User.hbm.xml

五月 09, 2016 8:39:13 下午 org.hibernate.cfg.Configuration doConfigure

INFO: HHH000041: Configured SessionFactory: null

五月 09, 2016 8:39:13 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)

五月 09, 2016 8:39:13 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000115: Hibernate connection pool size: 20

五月 09, 2016 8:39:13 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000006: Autocommit mode: false

五月 09, 2016 8:39:13 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql:///test]

五月 09, 2016 8:39:13 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

INFO: HHH000046: Connection properties: {user=root, password=****}

五月 09, 2016 8:39:13 下午 org.hibernate.dialect.Dialect <init>

INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect

五月 09, 2016 8:39:14 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService

INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)

五月 09, 2016 8:39:14 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>

INFO: HHH000397: Using ASTQueryTranslatorFactory

五月 09, 2016 8:39:14 下午 org.hibernate.tuple.PojoInstantiator <init>

INFO: HHH000182: No default (no-argument) constructor for class: entity.Student (class must be instantiated by Interceptor)

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000228: Running hbm2ddl schema update

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000102: Fetching database metadata

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000396: Updating schema

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000261: Table found: test.student

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000037: Columns: [birthday, sid, address, gender, sname]

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000108: Foreign keys: []

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000126: Indexes: [primary]

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000261: Table found: test.user

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000037: Columns: [uid, username, password]

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000108: Foreign keys: []

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.TableMetadata <init>

INFO: HHH000126: Indexes: [primary]

五月 09, 2016 8:39:14 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute

INFO: HHH000232: Schema update complete

org.hibernate.HibernateException: No CurrentSessionContext configured!

at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:986)

at service.UserDaoImpl.userLogin(UserDaoImpl.java:23)

at test.TestUserDaoImpl.testUserLogin(TestUserDaoImpl.java:15)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


正在回答

2 回答

jar包使用不對(duì)吧!

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

淡墨無殤 提問者

可能有jar包使用不對(duì),因?yàn)槲襧ar包換了好幾次版本 最后檢查了下是 hibernate.cfg.xml文件的<property name="hibernate.current_session_context_class">thread</property>沒有填寫對(duì) 之前是calss
2016-05-11 回復(fù) 有任何疑惑可以回復(fù)我~
#2

戰(zhàn)神無敵沖

親,能具體點(diǎn)不?
2016-12-06 回復(fù) 有任何疑惑可以回復(fù)我~

我的也是這個(gè)問題?。Q了幾個(gè)版本了,可還是 不對(duì)啊。

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

舉報(bào)

0/150
提交
取消

為什么我調(diào)試的代碼出錯(cuò) 提示 Session session = MyHibernateSessionFactory.getSessionFactory().getCurrentSession();出錯(cuò)

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

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

幫助反饋 APP下載

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

公眾號(hào)

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