Hibernate 运行报错,空指针异常

INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:orcl]

九月 15, 2018 11:39:14 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure

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

Exception in thread "main" java.lang.NullPointerException

at java.lang.String.(String.java:166)

at oracle.sql.CharacterSet.AL32UTF8ToString(CharacterSet.java:1628)

at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:834)

at oracle.jdbc.driver.DBConversion.CharBytesToString(DBConversion.java:773)

at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:816)

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:376)

at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:441)

at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)

at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)

at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)

at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:204)

at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:242)

at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117)

at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)

at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)

at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1827)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785)

at com.util.HibernateUtil.getSessionFactory(HibernateUtil.java:18)

at com.test.Test1.get(Test1.java:61)

at com.test.Test1.main(Test1.java:30)

hibernate.cfg.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">

<session-factory>

     <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

      <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>

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

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

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

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

</session-factory>

我看其他同学正确的代码,我出的问题是在方言那里就执行不下去了. 哪位大侠可以帮我看一下是什么问题吗

是oracle的字符集安装不好然后导致这部分取不到值? 如果这样的话,要怎么处理呢.

1个回答

你在配置里面试试这些

 ## Oracle

#hibernate.dialect org.hibernate.dialect.Oracle8iDialect
#hibernate.dialect org.hibernate.dialect.Oracle9iDialect
#hibernate.dialect org.hibernate.dialect.Oracle10gDialect
#hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
#hibernate.connection.username ora
#hibernate.connection.password ora
#hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl
#hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE

这是hibernate官方给的oracle配置信息,其它的可以去\hibernate-release-5.3.3.Final\project\etc\hibernate.properties文件中看看

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Hibernate 查询出现空指针异常?

在用Hibernate进行数据关联查询时总是出现空指针异常, [code="java"] public List queryAll() throws Exception { List all = null; String hql = "FROM Emp"; Query q = this.session.createQuery(hql); all = q.list(); this.session.close(); return all; } [/code] 进行测试出现空指针异常,提示all = q.list();有错! 请问大家是否遇到过此类问题呢? 要怎么解决呢? [code="java"] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Hibernate: select emp0_.empno as empno, emp0_.deptno as deptno1_, emp0_.ename as ename1_, emp0_.eage as eage1_, emp0_.esex as esex1_ from hibernate.emp emp0_ where emp0_.empno=? Exception in thread "main" java.lang.NullPointerException at org.hibernate.tuple.AbstractTuplizer.createProxy(AbstractTuplizer.java:249) at org.hibernate.persister.entity.BasicEntityPersister.createProxy(BasicEntityPersister.java:2831) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:218) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:163) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:655) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261) at org.hibernate.type.EntityType.resolve(EntityType.java:286) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530) at org.hibernate.loader.Loader.doQuery(Loader.java:436) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) at org.zhg.impl.EmpDAOImpl.queryByEmpno(EmpDAOImpl.java:54) at org.zhg.test.EmpTest.main(EmpTest.java:20) [/code]

hibernate整合spring空指针异常

![图片说明](https://img-ask.csdn.net/upload/201605/30/1464539308_703147.png) ![图片说明](https://img-ask.csdn.net/upload/201605/30/1464539322_588796.png) ![main()报空指针异常](https://img-ask.csdn.net/upload/201605/30/1464539336_766318.png) ![Junit提示错误](https://img-ask.csdn.net/upload/201605/30/1464539542_643013.png) ![applicationContext](https://img-ask.csdn.net/upload/201605/30/1464539645_240407.png)

hibernate数据库操作,总是报空指针异常

if (user.getUsername().length() > 0) { String hql = "select * from user where username = : username "; query = ses.createQuery(hql); //这一行总是报错,是不是查不到数据库有东西 query.setParameter("username",username); List User rt = query.list(); if(rt!=null){ req.setAttribute("register_error", "用户已经注册了!"); return "error"; } }

hibernate获取session报空指针

Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); 报空指针,是获取CurrentSession的时候报的,我该怎么办啊

添加hibernate支持测试空指针异常

![图片说明](https://img-ask.csdn.net/upload/201511/28/1448684104_515645.png) ![图片说明](https://img-ask.csdn.net/upload/201511/28/1448684078_938705.png) ![图片说明](https://img-ask.csdn.net/upload/201511/28/1448684091_921380.png) 看他提示貌似是获取会话为空,可是手动编写获取会话是可以正常显示的,搞不懂为什么添加的hibernate支持就不行

Hibernate createQuery空指针

select new vo.DwxxVo(dwName,sum(money)) from Jzxx j inner join j.dwxx d group by d.dwName 为什么这个语句会报错??? Jzxx 与 dwxx 是多对一的关系

数据库连接时总是空指针异常?测试表单信息无误,就是查询数据库时出错

java.lang.NullPointerException at com.Users.LoginServlet.doPost(LoginServlet.java:58) at javax.servlet.http.HttpServlet.service(HttpServlet.java:154) at javax.servlet.http.HttpServlet.service(HttpServlet.java:92) at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:274) at com.caucho.server.port.TcpConnection.run(TcpConnection.java:514) at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:527) at com.caucho.util.ThreadPool.run(ThreadPool.java:449) at java.lang.Thread.run(Unknown Source) 源代码: package com.Users; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import com.Service.LoginService; /** * 登录控制层 : LoginServlet * 将用户个人信息保存到 Session范围内 * 根据status对页面进行分别显示 * @author daichen * */ public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; /* * 注入 LoginService 服务 */ private LoginService loginService; @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doGet(req,res); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK"); User user = null; // 获取表单提交的登录信息 String userId = null; String password = null; userId = request.getParameter("userId"); password = request.getParameter("password"); // 先判断用户信息是否否为空 if(userId == null || "".equals(userId) || password == null || "".equals(password)) { // 用户信息有误 , 回到 login.jsp 页面 response.getWriter().println("<html><h3><font color='#f00'>对不起,你输入的信息有误 .请重新确认!</h3></font></html>"); return; } else { // 到数据表 user 中查找该用户 , 返回一个 User 对象 System.out.println(userId+" "+password); user = loginService.userLogin(userId,password); // 并对查询到的结果进行处理 if(user != null) { // 获取请求域的session对象 HttpSession session = request.getSession(); // 对三种权限分开添加到 Session 域中 if(user.getStatus() == 0){ session.setAttribute("geneUser", user); } if(user.getStatus() == 1){ session.setAttribute("admin", user); } if(user.getStatus() == 2){ session.setAttribute("superAdmin", user); } // 成功获取到用户信息 , 转到 index.jsp RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/jsp/index.jsp"); rd.forward(request, response); return; } else { // 查询没有该用户 , 转到 login.jsp response.getWriter().print("<h3><font color='#f00'>对不起,你还未注册用户 </h3></font>" + userId + "<h3><font color='#f00'>请先前去注册!</h3></font>"); RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/jsp/register.jsp"); rd.forward(request, response); return; } } } }

ssh框架,接口实现类调用service方法报空指针异常

``` //**实现类代码** String tname = saleName; String id = goodIds; //调用service层方法,传入两个参数。报空指针 int count = tpcCombinationSaleService.querySaleindexName(tname, id); //**service代码** public int querySaleindexName(String indexName,String id) throws com.sinovatech.common.exception.AppException; //**impl代码** @Override public int querySaleindexName(String indexName,String id) throws com.sinovatech.common.exception.AppException { indexName = indexName.trim(); String sql=""; if(!id.equals("")){ sql = "select * from DATA_RRYX.T_PC_COMBINATION_SALE Z where Z.NAME='" + indexName + "' and Z.id <> '"+id+"' and Z.is_delete = 'N'"; }else{ sql = "select * from DATA_RRYX.T_PC_COMBINATION_SALE Z where Z.NAME='" + indexName + "' and Z.is_delete = 'N'"; } return tpcCombinationSaleDAO.getRecordCountBySQL(sql); ``` 以上为代码,现在我运行测试类正常传参进去后,debug的时候走到调用service方法,没有走方法内部,就直接跳转到Thread类,的dispatchUncaughtException方法,然后就报了空指针异常,请问大佬们可能的原因是在哪里?

SSH搭建框架报空指针异常

我在进行SSH基础框架搭建的时候(就是还没有配置实体类),只是进行了整合配置,将事务管理和数据库连接配置在spring中,spring代码如下: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  xmlns:jdbc="http://www.springframework.org/schema/jdbc"   xmlns:jee="http://www.springframework.org/schema/jee"  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd"> <!-- 开启扫描组件 --> <context:component-scan base-package="cn.itcast.oa"/> <context:property-placeholder location="classpath:db.properties"/> <!-- 配置sessionfactory --> <bean id="sessionFactory" > <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> </bean> <!-- 配置连接数据库 --> <bean id="datasource" > <property name="url" value="${url}"/> <property name="username" value="${username}"/> <property name="password" value="${password}"/> <property name="driverClassName" value="${driverClassName}"/> </bean> <!-- 配置声明式事务管理(采用注解的方式) --> <!-- 配置事务管理器 --> <bean id="txManager" > <!-- 引用前边配置的SessionFactory --> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 注解驱动 --> <tx:annotation-driven transaction-manager="txManager"/>  </beans> 将sessionFactory中配置数据库连接的时候,就是<prorerty>中将数据库连接引进来的时候,就会报空指针异常,各位大牛能解答吗(纯自学SSH),环境是:Windows+Tomcat+oracle(虚拟机)

Hibernate4 SessionFactory 空指针

Configuration conf = new Configuration().configure(); StandardServiceRegistryBuilder srb = new StandardServiceRegistryBuilder().applySettings(conf.getProperties()); StandardServiceRegistry sr = srb.build(); SessionFactory sf = conf.buildSessionFactory(sr); 上面这样写有问题吗,为什么老是报空指针异常 配置文件 <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">1991</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.min_size">1</property> <property name="hibernate.c3p0.timeout">5000</property> <property name="hibernate.c3p0.max_statements">100</property> <property name="hibernate.c3p0.idle_test_period">3000</property> <property name="hibernate.c3p0.acquire_increment">2</property> <property name="hibernate.c3p0.validate">true</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="hbm2ddl.auto">update</property> <property name="show_sql">true</property> <property name="hibernate.format_sql">true</property> <mapping class="org.zmf.hibernate.entity.ReAddress"/> <mapping class="org.zmf.hibernate.entity.Users"/> <mapping class="org.zmf.hibernate.entity.News"/> </session-factory>

Hibernate项目报错,初学者困扰了好久了

最近开始学习hibernate框架,确实觉得比JDBC强大许多。目前在做一个网上评教系统,因为表关系联系比较紧密,所以决定用hibernate框架,刚刚开始的时候涉及到的实体类比较少,还是很顺利的,到后来,实体和关系稍微复杂了一点,问题就出来了。困扰了我好久,简直快要折磨死我了,这里出现了错误,后面的完全就没法做。 ![图片说明](https://img-ask.csdn.net/upload/201505/04/1430698916_56844.png) 看报错,其实也能大致知道是Teacher.java或Teacher.hbm.xml出了问题,可是我检查了不下10遍了,实在是看不出来哪里的问题,贴出我的代码 Teacher.java package cn.pj.zyf.domain; import java.io.Serializable; import java.util.Set; public class Teacher implements Serializable{ private String tid; private String tname; private String pic; private String description; private Set<Course> list_courses; public String getTid() { return tid; } public void setTid(String tid) { this.tid = tid; } public String getTname() { return tname; } public void setTname(String tname) { this.tname = tname; } public String getPic() { return pic; } public void setPic(String pic) { this.pic = pic; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Set<Course> getList_courses() { return list_courses; } public void setList_courses(Set<Course> list_courses) { this.list_courses = list_courses; } } Teacher.hbm.xml <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="cn.pj.zyf.domain.Teacher" table="teacher"> <id name="tid" column="tid" type="string" > <generator class="assigned"></generator> </id> <property name="tname" column="tname" type="string"></property> <property name="pic" column="pic" type="string"></property> <property name="description" column="description" type="string"></property> <!-- 教师 与 课程 一对多关联 --> <set name="courses" cascade="all" inverse="false"> <!-- key是用来描述外键 --> <key> <column name="tid"></column> </key> <one-to-many class="cn.pj.zyf.domain.Course" /> </set> </class> </hibernate-mapping>

hibernate 运行报错帮忙看看处理下,谢谢

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml Exception in thread "main" org.hibernate.MappingException: invalid configuration at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2158) at org.hibernate.cfg.Configuration.configure(Configuration.java:2075) at org.hibernate.cfg.Configuration.configure(Configuration.java:2054) at com.chenyanwu.main.GetDept.main(GetDept.java:17) Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 25; 文档无效: 找不到语法。 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:227) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:604) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3122) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649) at org.dom4j.io.SAXReader.read(SAXReader.java:465) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2155) ... 3 more

我用hibernateTemplate的find查询出现空指针异常

当查询的那一行数据的外键没有值时可以查得到,但外键有值时则报空指针异常,一下是hibernate的源码部分 public Number selectById(String id){ // TODO Auto-generated method stub String hql="from Number wherer id=?";//报错行 List<Number> list=hibTemplate.find(hql,id); if(list.size()>0){ return list.get(0); }else{ return null; } } 这里id是主键 一下是错误页面: javax.servlet.ServletException: java.lang.NullPointerException org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:518) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421) root cause java.lang.NullPointerException org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372) org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121) org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232) org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173) org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87) org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862) org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830) org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266) org.hibernate.type.EntityType.resolve(EntityType.java:303) org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116) org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) org.hibernate.loader.Loader.doQuery(Loader.java:717) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) org.hibernate.loader.Loader.doList(Loader.java:2145) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) org.hibernate.loader.Loader.list(Loader.java:2024) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375) org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308) org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106) org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849) org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840) org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836) com.etc.dao.NumberDAOHibernateTemplateImpl.selectById(NumberDAOHibernateTemplateImpl.java:19) com.etc.service.NumberServiceImpl.delNum(NumberServiceImpl.java:32) com.etc.action.NumberAction.deleteNumber(NumberAction.java:115)

spring+hibernate query.list 报空指针

Hibernate: select count(*) as col_0_0_ from profession profession0_ where profession0_.dept_no=? Hibernate: select top 12 profession0_.profession_No as profession1_1_, profession0_.profession_name as profession2_1_, profession0_.dept_no as dept3_1_ from profession profession0_ where profession0_.dept_no=? order by profession0_.profession_No desc 2009-2-16 19:10:01 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet default threw exception java.lang.NullPointerException at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372) at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121) at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862) at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830) at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266) at org.hibernate.type.EntityType.resolve(EntityType.java:303) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) at org.hibernate.loader.Loader.doQuery(Loader.java:717) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2145) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) at com.top.daoHibernateImpl.HibernateGeneric.pagedQuery(HibernateGeneric.java:264) Assert.hasText(hql); Assert.isTrue(pageNo >= 1, "pageNo should start from 1"); // Count查询 String countQueryString = PageFactory.getTotalCountHqlByHql(hql); List countlist = this.find(countQueryString, values); int totalCount = ((Integer) countlist.get(0)).intValue(); if (totalCount < 1) return new Page(); // 实际查询返回分页对象 Query query = createQuery(hql, values); int startIndex = PageFactory.getStartIndex(pageNo, pageSize); List results = query.setFirstResult(startIndex).setMaxResults(pageSize) .list();//本行报空指针 return PageFactory.createPage(pageNo, pageSize, totalCount, results); [b]问题补充:[/b] 大家好本问题已经解决!~ 我才本站其他贴上看到了同样的贴,再此也谢谢那位仁兄!~

hibernate 空指针异常问题

package com.yuqidi.mapping; import java.util.Iterator; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class mappingTest { private static SessionFactory sessionFactory; @BeforeClass public static void beforeClass() { new SchemaExport(new AnnotationConfiguration().configure()).create(false, true); sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); } @AfterClass public static void afterClass() { sessionFactory.close(); } @Test public void testSaveGroup() { User u1 = new User(); u1.setName("u1"); User u2 = new User(); u2.setName("u2"); Group g = new Group(); g.setName("g1"); g.getUsers().add(u1); g.getUsers().add(u2); u1.setGroup(g); u2.setGroup(g); Session s = sessionFactory.getCurrentSession(); s.beginTransaction(); s.save(g); s.getTransaction().commit(); } @Test public void testGetGroup(){ testSaveGroup(); Session s = sessionFactory.getCurrentSession(); s.beginTransaction(); Group g=(Group)s.get(Group.class, 0); System.out.println(g.getName()); s.getTransaction().commit(); } @Test public void testSchemaExport() { new SchemaExport(new AnnotationConfiguration().configure()).create(false, true); } public static void main(String[] args) { beforeClass(); } } 用Junit 测试时会报空指针异常;去掉System.out.println(g.getName());可以通过测试,情各位指教

hibernate mysql 报错 简单问题

[code="java"] Hibernate: update tb_news_radio set state='审核否决', shenhe_name='admin', shenhe_time=now() where id=135 2012-02-05 12:31:08,984 [http-5000-1] ERROR org.hibernate.util.JDBCExceptionReporter - Data truncation: Data truncated for column 'shenhe_time' at row 1 org.hibernate.exception.DataException: could not execute update query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:107) at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:419) at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283) at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1168) at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117) at com.acec.house.service.admin.AdminManager.shipinPass(AdminManager.java:442) at com.acec.house.service.admin.AdminManager$$FastClassByCGLIB$$c5f9ca65.invoke(<generated>) at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635) at com.acec.house.service.admin.AdminManager$$EnhancerByCGLIB$$2536b346.shipinPass(<generated>) at com.acec.house.actions.admin.AdminAction.shipinPass(AdminAction.java:1002) 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 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:148) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:93) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:128) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:104) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:148) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:128) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:468) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'shenhe_time' at row 1 at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java:717) at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3031) at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1241) at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102) at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:98) ... 87 more 报这个错。我在数据库直接执行sql语句可以执行。 public void shipinPass(Integer id, String pass, String userName) { if(pass.equals("true")) manager.createQuery("update NewsRadioEO set state='审核通过',shenheName='"+userName+"',shenheTime=now() where id="+id).executeUpdate(); else manager.createQuery("update NewsRadioEO set state='审核否决',shenheName='"+userName+"',shenheTime=now() where id="+id).executeUpdate(); } 这样却不行了,我把shenheTime=now() 改成shenheTime='2012-05-05'却可以执行 求指导 [/code]

hibernate hql 报错 用sql语句则正常运行

在网上购买了一个jsp空间,之前的运行都是正常的,昨天改了改数据库就不能正常访问了。报错 [code="java"]SELECT command denied to user 'bjettccom'@'127.0.0.1' for table 'notice' [/code] 数据库代码应该都是正确的 后来发现hibernate的createQuery [code="java"]sess.createQuery("from Pics").list();[/code] 的语句出问题,改成sess.createSQLQuery则正常,为什么?

hibernate5.0.6报错Unknown entity

网上这个错误的解决方法很多,我都试过了但是没有一个行的,确认我的配置文件没写错,请问是什么问题? **报错** Exception in thread "main" org.hibernate.MappingException: Unknown entity: com.hibernate.Student at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:781) at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1520) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:100) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192) at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177) at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73) at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:679) at org.hibernate.internal.SessionImpl.save(SessionImpl.java:671) at org.hibernate.internal.SessionImpl.save(SessionImpl.java:666) at com.hibernateservice.StudentTest.main(StudentTest.java:33) **hibernate.cfg.xml:** ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="SessionFac"> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.password">1234</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate</property> <property name="hibernate.connection.username">root</property> <!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> --> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <mapping resource="com/hibernate/Student.hbm.xml"/> </session-factory> </hibernate-configuration> ``` **Student.hbm.xml** ``` <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "dtd/hibernate-mapping-3.0.dtd"> <!-- Generated 2015-12-22 14:24:24 by Hibernate Tools 3.4.0.CR1 --> <hibernate-mapping > <class name="com.hibernate.Student" table="t_student"> <id name="id" column="stuId" type="java.lang.Integer"> <generator class="native"/> </id> <properties name="name" column="stuName" type="java.lang.String"></properties> </class> </hibernate-mapping> ``` **Student.java:** ``` package com.hibernate; public class Student { int id; String name; /** * @return the id */ public long getId() { return id; } /** * @param id the id to set */ public void setId(int id) { this.id = id; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } public Student() { // TODO Auto-generated constructor stub } } ``` **StudentTest.java:** ``` package com.hibernateservice; import com.hibernate.Student; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; public class StudentTest { public StudentTest() { // TODO Auto-generated constructor stub } public static void main(String[] args) { Configuration config = new Configuration().configure(); org.hibernate.service.ServiceRegistry registry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); SessionFactory sessionFactory = config.buildSessionFactory(registry); Session session = sessionFactory.openSession(); session.beginTransaction(); Student s = new Student(); s.setName("张三"); s.setId(0); session.save(s); session.getTransaction().commit(); session.close(); sessionFactory.close(); } } ``` **目录:** ![图片说明](https://img-ask.csdn.net/upload/201512/23/1450800820_219127.png)

关于spring+hibernate的报错

![![图片说明](https://img-ask.csdn.net/upload/201605/15/1463288705_179382.png)图片说明](https://img-ask.csdn.net/upload/201605/15/1463288695_514054.png)

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

差点跪了...

最近微信又搞出了一个大利器,甚至都上了热搜,当然消息最敏捷的自媒体人,纷纷都开通了自己的视频号。01 视频号是什么呢?视频号是微信体系内的短视频,它不同...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

Vue回炉重造之router路由(更新中)

你好,我是Vam的金豆之路,可以叫我豆哥。2019年年度博客之星、技术领域博客专家。主要领域:前端开发。我的微信是 maomin9761,有什么疑问可以加我哦,自己创建了一个微信技术交流群,可以加我邀请你一起交流学习。最后自己也创建了一个微信公众号,里面的文章是我自己精挑细选的文章,主要介绍各种IT新技术。欢迎关注哦,微信搜索:臻美IT,等你来。 欢迎阅读本博文,本博文主要讲述【】,文字通...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大胆预测下未来5年的Web开发

在2019年的ReactiveConf 上,《Elm in Action》的作者Richard Feldman对未来5年Web开发的发展做了预测,很有意思,分享给大家。如果你有机会从头...

立即提问
相关内容推荐