hibernate的session.save()为什么没有执行

User 是一个有id username passwrod的类
hb.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">



<!-- 先配置数据库链接信息 -->
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/dxlin
root
duanlin113
none
<!-- 数据库方言 -->
org.hibernate.dialect.MySQLDialect


User.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">



<!-- 主键生成策略 -->



</class>
</hibernate-mapping>
Test 类

package com.dxlin.hibtest;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;

import com.dxlin.pojo.User;

public class Test {
public static void main(String args[]) {
System.out.println("1");
//1.新建立Configuration对象
Configuration cfg = new Configuration();
cfg.configure("hb.cfg.xml");
System.out.println("2");
//2.通过Configuration新建sessionFactory对象
ServiceRegistry registry = new StandardServiceRegistryBuilder()
.applySettings(cfg.getProperties())
.build();
SessionFactory sf = cfg.buildSessionFactory(registry);
System.out.println("3");
//3.通过sessionFactory得到session
Session session = sf.openSession();
System.out.println("4");
//4.通过session对象得到Transaction对象
Transaction tx = session.beginTransaction();
System.out.println("5");
//保存数据
User user = new User();
user.setUsername("DL2");
user.setPassword("002");
session.save(user);
System.out.println("6");
//提交事务

    tx.commit();
    System.out.println("7");
    //关闭session
    session.close();
    System.out.println("8");
} 

}
代码不报错,运行为
图片说明

1个回答

我遇见过,是因为我的主键生成策略是native但是主键手动添加了,改成assigned就行了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
hibernate 采用session.save(Object)方法保存不了数据

代码如下: bean类: package org.hibernate.sample.modle; import java.io.Serializable; import org.apache.commons.lang.builder.ToStringBuilder; /** @author Hibernate CodeGenerator */ public class Student implements Serializable { private static final long serialVersionUID = 1L; /** identifier field */ private Integer studentId; /** persistent field */ private String name; /** persistent field */ private String sex; /** persistent field */ private Integer age; /** full constructor */ public Student(String name, String sex, Integer age) { this.name = name; this.sex = sex; this.age = age; } /** default constructor */ public Student() { } public Integer getStudentId() { return this.studentId; } public void setStudentId(Integer studentId) { this.studentId = studentId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getSex() { return this.sex; } public void setSex(String sex) { this.sex = sex; } public Integer getAge() { return this.age; } public void setAge(Integer age) { this.age = age; } public String toString() { return new ToStringBuilder(this) .append("studentId", getStudentId()) .toString(); } } 映射配置: <?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 package="org.hibernate.sample.modle"> <!-- Created by the Middlegen Hibernate plugin 2.1 http://boss.bekk.no/boss/middlegen/ http://www.hibernate.org/ --> <class name="Student" table="student" dynamic-update="true"> <id name="studentId" type="java.lang.Integer" column="student_id" unsaved-value="0"> <generator class="native"/> </id> <property name="name" type="java.lang.String" column="name" not-null="true" length="45"/> <property name="sex" type="java.lang.String" column="sex" not-null="true" length="45"/> <property name="age" type="java.lang.Integer" column="age" not-null="true" length="45"/> <!-- Associations --> </class> </hibernate-mapping> 配置文件: <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <!-- SessionFactory 配置 --> <session-factory> <!-- MySQL配置 --> <!-- 数据库URL --> <property name="connection.url"> <![CDATA[ jdbc:mysql://localhost:3306/bms?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8]]> </property> <!-- 数据库JDBC驱动 --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <!--数据库用户名 --> <property name="connection.username"><![CDATA[root]]></property> <!--数据库用户密码 --> <property name="connection.password"></property> <!--dialect ,每个数据库都有其对应的Dialet以匹配其平台特性 --> <property name="dialect"> org.hibernate.dialect.MySQLDialect</property> <!-- 是否将运行期生成的SQL输出到日志以供调试 --> <property name="show_sql">true</property> <!--映射文件配置,注意配置文件名必须包含其相对于根的全路径 --> <mapping resource="org/hibernate/sample/modle/Student.hbm.xml"/> </session-factory> </hibernate-configuration> 测试类: package test; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.Session; import org.hibernate.sample.modle.Student; import junit.framework.Assert; import junit.framework.TestCase; public class HibernateTest extends TestCase { Session session = null; /** * JUnit中setUp方法在TestCase初始化的时候会自动调用 一般用于初始化公用资源 此例中,用于初始化Hibernate Session */ protected void setUp() { try { /** * 采用hibernate.properties配置文件的初始化代码: Configuration config = new * Configuration(); config.addClass(TUser.class); */ // 采用hibernate.cfg.xml配置文件 // 请注意初始化Configuration时的差异: // 1.Configuration的初始化方式 // 2.xml文件中已经定义了Mapping文件,因此无需再Hard Coding导入 // POJO文件的定义 Configuration config = new Configuration().configure(); SessionFactory sessionFactory = config.buildSessionFactory(); session = sessionFactory.openSession(); } catch (HibernateException e) { e.printStackTrace(); } } /** * 与setUp方法相对应,JUnit TestCase执行完毕时,会自动调用tearDown方法 一般用于资源释放 * 此例中,用于关闭在setUp方法中打开的Hibernate Session */ protected void tearDown() { try { session.close(); } catch (HibernateException e) { e.printStackTrace(); } } /** * 对象持久化(Insert)测试方法 * * JUnit中,以”test”作为前缀的方法为测试方法,将被JUnit自动添加 到测试计划中运行 */ public void testInsert() { try { Student student = new Student(); // student.setStudentId( Integer.valueOf(1)); student.setName("哈哈"); student.setSex("男"); student.setAge(Integer.valueOf(13)); session.save(student); session.flush(); System.out.println(student.getStudentId()); } catch (HibernateException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } } /** * 对象读取(Select)测试 请保证运行之前数据库中已经存在name=’Erica’的记录 */ public void testSelect() { String hql = " from Student where name='哈哈'"; try { Query query= session.createQuery(hql); List list=query.list(); Student student = (Student) list.get(0); Assert.assertEquals(student.getName(), "哈哈"); } catch (HibernateException e) { e.printStackTrace(); Assert.fail(e.getMessage()); } } } [b]问题补充:[/b] 数据库表的 create table student( student_id integer unsigned auto_increment, name varchar(45) not null, sex varchar(45) not null, age integer not null );

session.save()会立即同步状态到数据库,不解!

先看代码: [code="java"] public static void main(String[] args) throws Exception { Configuration cfg = new Configuration(); SessionFactory sf = cfg.configure().buildSessionFactory(); Session session = sf.openSession(); //session.setFlushMode(FlushMode.MANUAL); session.beginTransaction(); Parent p = new Parent(); p.setName("hello"); session.save(p); System.out.println(1); p.setName("world"); System.out.println(2); session.getTransaction().commit(); session.close(); } [/code] 这是我的一段测试代码,Parent类除了id以外仅有一个name属性,我执行这段代码,在控制台的输出是这样的: [code="java"] Hibernate: insert into parent (name) values (?) 1 2 Hibernate: update parent set name=? where id=? [/code] 我的疑问是,为什么save方法会在打印语句之前将sql语句发送到数据库,是立即执行的,update方法的行为可以理解,提交事务时才同步到数据库,我记得以前save方法也不会立即发送sql的,而是flush或者commit时才会,我用的hibernate是3.3.1.GA版本的,难道是这个原因吗? 当我把session.setFlushMode(FlushMode.MANUAL)的注释去掉之后输出变成了这样: [code="java"] Hibernate: insert into parent (name) values (?) 1 2 [/code] 因为没有手动显式调用flush,所有后来的update并没有发出,但是save仍然是立即同步的,不解啊!

为什么session.delete()能找到并删除已经分离的数据库中要删的数据?

为什么detached状态下,session.delete()能找到并删除已经分离的数据库中要删的数据? 先session.save( t );再session.close()成detached状态。然后创建个新的session2,再session2.delete(t); 明明是detached状态,而且session已经关闭了,为什么hibernate还知道内存中的 t 和数据库中的列有关系。session和数据库不是已经关闭和脱离了吗?为什么hibernate还能准确的知道这个t对象就是对应数据库中的某个数据?

getHibernateTemplate().save()与session.save()有什么区别啊,哪个更好啊?

如题: getHibernateTemplate().save()与getHibernateTemplate().getSessionFactory().getCurrentSession().save()有什么区别啊,哪个更好啊?

hibernate 的save保存

hibernate session的save保存一条数据提交一次事务快 还是先全部保存到session中,提交一次事务快 Session session = null; Transaction transaction = null; try { session = sessionFactory.openSession(); transaction = session.beginTransaction(); for(Residents s:allResidents){ session.save(s); } transaction.commit(); } catch (Exception e) { if (transaction != null) { transaction.rollback(); } throw e; } finally { if (session != null) { session.close(); } }

关于hibernate的session.saveOrUpdate()底层实现的问题

这个问题会有点模糊,因为我的目的是想知道 session的增删改查底层实现原理,所以我详细看了下(以saveOrUpdate()方法为主)saveOrUpdate的流程,它的底层相当的庞大,我很认真的看源码,但是其中有很大一部分我都看不懂,我想知道从session.saveOrUpdate(Object javaBean)此方法开始到结束,那个作者是怎么想出来的,那么多的成员变量和局部变量,都是用在哪里的,要怎么看hibernate的源码? Session.saveOrUpdate()目的是为了 新增或者更新 ---执行sql语句 insert或者update 但是insert 或update是自动生成所以要有org.hibernate.sql包来生成sql,还有事物的设置, 但是我能想到的做一个hibernate的需求就这么多了,可是源码中的变量和类多的都不敢想象,我在想它们都用在那个流程,起到什么作用,真是没有办法啦、啊啊啊啊啊啊 最好-->能够给我提供一些好的书本或者文章(专门针对hibernate底层框架<其他的框架spring、struts2也要>的书或者文章),我在网上完全搜不到hibernate的底层的知识,根本就没有半个人写过关于hibernate底层的东西,我渴望了解它的底层,希望有IT界的朋友帮帮忙,我会感激不尽,真的、谢谢

Hibernate中的session的save方法。

我正在学习hibernate框架,然后在做一个插入的时候遇到了一个问题。通过跟踪我发现在执行session.save(obj);方法时,程序就不动了。并且在获取session时还打印出下面红色的信息。 请问一个是什么原因以及怎么解决呢? ![图片说明](https://img-ask.csdn.net/upload/201604/30/1462019362_918790.png) ``` public int insertClient(Client client) { // TODO Auto-generated method stub //HibernateUtil.closeSession(); System.out.println("client insert1 :"); Session session = HibernateUtil.currentSession(); //System.out.println(session); System.out.println("client insert2 :"); Transaction transaction = session.beginTransaction(); System.out.println("client insert3 :"); System.out.println(client); Integer s= (Integer) session.save(client); System.out.println("client insert4 :"+s); try { transaction.commit(); } catch (Exception e) { transaction.rollback(); } finally { HibernateUtil.closeSession(); } System.out.println("row :"+s); return s; } ``` ``` public class HibernateUtil { public static final SessionFactory sessionFactory; static { try { // 使用默认的hibernate.cfg.xml配置文件创建Configuration实例 Configuration cfg = new Configuration() .configure(); // 以Configuration实例来创建SessionFactory实例 ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder() .applySettings(cfg.getProperties()).build(); sessionFactory = cfg.buildSessionFactory(serviceRegistry); } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } // ThreadLocal可以隔离多个线程的数据共享,因此不再需要对线程同步 public static final ThreadLocal<Session> session = new ThreadLocal<Session>(); public static Session currentSession() throws HibernateException { Session s = session.get(); System.out.println("session get:"); // 如果该线程还没有Session,则创建一个新的Session if (s == null) { s = sessionFactory.openSession(); // 将获得的Session变量存储在ThreadLocal变量session里 session.set(s); } return s; } public static void closeSession() throws HibernateException { Session s = session.get(); if (s != null) s.close(); session.set(null); } } ```

hibernate save新对象时出现属性全部为空异常

写代码时候要把一个用户对象保存到数据库,代码如下: ``` Account account = user; System.out.println(account.getUserid()); Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(account); session.getTransaction().commit(); session.close(); ``` 其中System.out那一步可以正确的输出id,但是控制台输出的SQL语句却是这样的: Hibernate: insert into account (email, firstname, lastname, status, addr1, addr2, city, state, zip, country, phone) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) values全部为空,然后程序报无法执行SQL的异常=。=不知道这是为什么,学生党,求大神前辈解救。。

Hibernate 中getSession().save() 保存不到数据库

为什么我的Hibernate 中getSession().save() 保存不到数据库 我的dao中怎么写的: [code="java"] /** * 保存实体 */ public void save(T o) { getSession().persist(o); } [/code] 我在测试单元这样写的: [code="java"] @Test public void testSave() { ApplicationContext cxt = new ClassPathXmlApplicationContext("/applicationContext.xml"); buyerService = (BuyerService)cxt.getBean("buyerService"); Buyer buyer = new Buyer("dengmingti","123456","test@sina.com"); ContactInfo contactInfo = new ContactInfo(); contactInfo.setAddress("百色市朝阳区左家庄"); contactInfo.setMobile("13671323507"); contactInfo.setPhone("010-64469090-9"); contactInfo.setPostalcode("531500"); buyer.setContactinfo(contactInfo); buyer.setGender("男"); buyer.setRealname("刘德华"); buyer.setRegTime(new Date()); buyerService.save(buyer); }[/code] 在dao中写 Transaction tran=getSession().beginTransaction(); tran.commit();也没有用 如果我的测试单元这样写怎可以保存到数据库中: [code="java"] protected static ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/applicationContext.xml"); protected static SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory"); @Test public void testSave() { Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); Buyer buyer = new Buyer("dengmingrun","123456","test@sina.com"); ContactInfo contactInfo = new ContactInfo(); contactInfo.setAddress("北海市朝阳区左家庄"); contactInfo.setMobile("13671323507"); contactInfo.setPhone("010-64469090-9"); contactInfo.setPostalcode("533000"); buyer.setContactinfo(contactInfo); buyer.setGender("男"); buyer.setRealname("张学友"); buyer.setRegTime(new Date()); session.save(buyer); tx.commit(); session.close(); }[/code] 我怎样才能使用buyerService.save(buyer);存到数据库中呀?

hibernate4为什么在执行save ()后直接查询直接查询不到数据?

![图片说明](https://img-ask.csdn.net/upload/201511/18/1447830636_399666.png)hibernate4为什么在执行save ()后直接查询直接查询不到数据 同样的配置在hibernate3这样是能查询到数据的,换到hibernate4就是查不到, 就像save()操作没有把对象缓存一样,这样是为什么呀?下面是配置 <property name="dialect"> org.hibernate.dialect.MySQL5InnoDBDialect </property> <property name="current_session_context_class">jta</property> <property name="hibernate.transaction.factory_class"> org.hibernate.transaction.JTATransactionFactory </property> <property name="hibernate.transaction.manager_lookup_class"> com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup </property> <property name="connection.release_mode">auto</property> <property name="hibernate.transaction.flush_before_completion"> true </property> <property name="hibernate.transaction.auto_close_session"> true </property> 事务用的JTA java代码时在同一个事务里添加和查询的: User user = new User() user.setOid("123"); ... Dao.save(user); list lst = Dao.query("User","where oid='123'"); 结果lst为空 理论上save后对象应该缓存在Session里的吧,查询的话也应该查询到缓存里对象吧,可是为什么查询不到呢? 经过验证,对象确实在session里,但是在同一个事务内就是查询不到,为什么呢?

hibernate执行保存对象时出现异常:org.hibernate.exception.GenericJDBCException

hibernate执行保存对象时出现异常: org.hibernate.exception.GenericJDBCException: could not insert: [com.hibernate.domain.User] Caused by: java.sql.SQLException: Field 'user_id' doesn't have a default value 具体的代码和配置如下: **hibernate.cfg.xml:** <hibernate-configuration> <session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/hibernate3</property> <property name="connection.username">root</property> <property name="connection.password">ytkj</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- SQL dialect --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management --> <!-- <property name="current_session_context_class">thread</property> --> <!-- Disable the second-level cache --> <!-- <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> --> <!-- Echo all executed SQL to stdout --> <!-- show sql dml --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <!-- <property name="hbm2ddl.auto">update</property> --> <mapping resource="com/hibernate/domain/User.hbm.xml"/> </session-factory> </hibernate-configuration> ------------------------------------------------------------------------ 建表语句(成功): CREATE TABLE `t_user` ( `user_id` int(11) NOT NULL, `user_name` varchar(20) default NULL, `user_age` int(11) default NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ------------------------------------------------------------------ **测试类:** package com.hibernate.manager; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import com.hibernate.domain.User; import com.hibernate.util.HibernateUtil; public class UserManager { public static void main(String[] args) { SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); Session session = sessionFactory.openSession(); Transaction ts = session.beginTransaction(); User user = new User(); user.setId(1); user.setName("zhangsan"); user.setAge(21); session.save(user); ts.commit(); session.close(); sessionFactory.close(); } } ----------------------------------------------------------------------- **User.hbm.xml:** <hibernate-mapping package="com.hibernate.domain"> <class name="User" table="t_user"> <id name="id" column="user_id"> <generator class="native"/> </id> <!-- <id name="id" type="int" column="user_id"/> --> <property name="name" type="string" column="user_name"/> <property name="age" type="int" column="user_age"/> </class> </hibernate-mapping> ------------------------------------------------------------------------- 以上代码执行过后,就包上面的异常。 如果不使用id生成策略(及时没有generator标签),则可以insert成功。 请问这问题是出在哪里?高手指点。

在Spring集成Hibernate后,进行save操作报错

在进行save操作时抛出Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.异常 在网上找了许久,全是千篇一律。基本上都是说在web.xml的过滤器加FlushMode,但是我这个只有Spring+Hibernate,哪来的web.xml。也有说加事务处理的,但是我加了事务,测试了无数遍,还是不行,请大神们帮忙下,谢谢,下面是我的xml配置 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!-- Stock business object --> <bean id="stockBo" class="com.yiibai.stock.bo.impl.StockBoImpl" > <property name="stockDao" ref="stockDao" /> </bean> <bean id="stockDao" class="com.yiibai.stock.dao.impl.StockDaoImpl" > <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributes"> <props> <prop key="save">PROPAGATION_SUPPORTS</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="dataSource" ref="dataSource" /> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="productBoProxy" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target" ref="stockDao" /> <property name="interceptorNames"> <list> <value>transactionInterceptor</value> </list> </property> </bean> </beans> 下面是具体错误信息 Exception in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. at org.springframework.orm.hibernate5.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1093) at org.springframework.orm.hibernate5.HibernateTemplate.lambda$update$13(HibernateTemplate.java:658) at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:383) at org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:349) at org.springframework.orm.hibernate5.HibernateTemplate.update(HibernateTemplate.java:657) at org.springframework.orm.hibernate5.HibernateTemplate.update(HibernateTemplate.java:652) at com.yiibai.stock.dao.impl.StockDaoImpl.update(StockDaoImpl.java:17) at com.yiibai.stock.bo.impl.StockBoImpl.update(StockBoImpl.java:20) at com.yiibai.common.App.main(App.java:28)

hibernate中sessionFactory问题

一对多映射 感觉没错,求解啊!!! ``` public class HibernateUtil { private static SessionFactory sessionFactory; private static Session session; static { //创建configuration对象,读取hibernate.cfg.xml文件,完成初始化 Configuration config = new Configuration().configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry(); sessionFactory = config.buildSessionFactory(serviceRegistry); //16 } //获取sessionFactory public static SessionFactory getSessionFactory() { return sessionFactory; } //获取session对象 public static Session getSession() { session = sessionFactory.openSession(); return session; } //关闭会话 public static void closeSession(Session session) { if(session!=null) { session.close(); } } } public class Test { public static void main(String[] args) { add(); //14 } //将学生添加到班级 public static void add() { Grade g = new Grade("java一班", "java软件开发一班"); Student s1 = new Student("张三", "男"); Student s2 = new Student("慕女神","女"); g.getStudents().add(s1); g.getStudents().add(s2); //保存班级、学生信息 Session session = HibernateUtil.getSession(); //29 Transaction transaction = session.beginTransaction(); session.save(g); session.save(s1); session.save(s2); transaction.commit(); HibernateUtil.closeSession(session); } } 错误信息: Exception in thread "main" java.lang.ExceptionInInitializerError at com.imooc.entity.Test.add(Test.java:29) at com.imooc.entity.Test.main(Test.java:14) Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185) at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:385) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1790) at com.imooc.util.HibernateUtil.<clinit>(HibernateUtil.java:16) ... 2 more Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:138) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:341) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:507) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163) ... 6 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135) ... 15 more Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for student in class com.imooc.entity.Grade at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:316) at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310) at org.hibernate.mapping.Property.getGetter(Property.java:321) at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:444) at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:200) at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:82) ... 20 more ```

hibernate 出错 java.lang.ClassCastException

[size=medium]刚刚学hibernate ,运行时出现异常 Exception in thread "main" java.lang.ClassCastException: java.lang.String at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:377) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:112) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate( 下面是代码: [code="java"] public class TestHibernate { Configuration cfg; SessionFactory sf; Session session; public static void main(String[] args){ TestHibernate test = new TestHibernate(); test.work(); } public void work(){ cfg = new Configuration().configure(); sf = cfg.buildSessionFactory(); session = sf.openSession(); User user = new User(); user.setUserID("22"); user.setPassword("d"); user.setUsername("c"); session.beginTransaction(); session.save(user); session.getTransaction().commit(); } } [/code] pojo的代码: [code="java"] public class User implements Serializable { private String userID; private String username; private String password; public String getUserID() { return userID; } public void setUserID(String userID) { this.userID = userID; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } [/code] [code="java"] <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="vo.User" table="myproject1_t_user" catalog="myproject1"> <composite-id name="userID" class="vo.User"> <key-property name="userID" type="java.lang.String"> <column name="user_id" /> </key-property> <key-property name="username" type="java.lang.String"> <column name="username" /> </key-property> <key-property name="password" type="java.lang.String"> <column name="password" /> </key-property> </composite-id> </class> </hibernate-mapping> [/code][/size]

让我绝望了,怎么都解决不了,求求大神帮帮忙。Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

``` User.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"> <hibernate-mapping > <class name="com.pojo.User" table="u_user"> <id name="userId" column="user_id"> <!-- generator :时指定主键的生成方式,是固定值的选取一个 --> <!-- native 是使用本地数据库的自动增长能力 --> <generator class="native"></generator> </id> <property name="userName" column="user_name"></property> <property name="userSex" column="user_sex"></property> <property name="userAge" column="user_age"></property> <property name="userPrice" column="user_price"></property> </class> </hibernate-mapping> ``` ``` 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"> <hibernate-configuration> <session-factory> <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/test?useSSL=false&amp;serverTimezone=UTC</property> <property name="connection.username">root</property> <property name="connection.password">12345678</property> <property name="dialect">org.hibernate.dialect.MySQL8Dialect</property> <mapping resource="com/pojo/User.hbm.xml"/> </session-factory> </hibernate-configuration> 实体类 package com.pojo; public class User { private Integer userId; private String userName; private String userSex; private int userAge; private double userPrice; public User() { } public User(String userName, String userSex, int userAge, double userPrice) { super(); this.userName = userName; this.userSex = userSex; this.userAge = userAge; this.userPrice = userPrice; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getUserSex() { return userSex; } public void setUserSex(String userSex) { this.userSex = userSex; } public int getUserAge() { return userAge; } public void setUserAge(int userAge) { this.userAge = userAge; } public double getUserPrice() { return userPrice; } public void setUserPrice(double userPrice) { this.userPrice = userPrice; } } ``` 测试类 package com.pojo; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import com.pojo.User; public class TestDemo { public static void main(String[] args) { //Configuration cfg = new Configuration().configure(); // ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build(); //SessionFactory sf = cfg.buildSessionFactory(sr); StandardServiceRegistry sr=new StandardServiceRegistryBuilder().configure().build(); SessionFactory sf=new MetadataSources(sr).buildMetadata().buildSessionFactory(); Session session = sf.openSession(); Transaction ts = session.beginTransaction(); User user = new User("金毛","女",2,2000.56); session.save(user); ts.commit(); session.close(); sf.close(); } ``` ``` } ``` log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:228) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:207) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:692) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:727) at pojo.HibernateTest.main(HibernateTest.java:23) Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:254) ... 14 more ``` 这个是jar包 ![图片说明](https://img-ask.csdn.net/upload/202005/13/1589381247_907590.png)

hibernate一对多级联保存机制是什么

Configuration configuration = new Configuration().configure(); SessionFactory sessionFactory = configuration.buildSessionFactory(); Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); Order order = new Order(); order.setOrderName("订单2"); Ticket ticket = new Ticket("优惠券1",order); Ticket ticket1 = new Ticket("优惠券2",order); order.getTickets().add(ticket); order.getTickets().add(ticket1); session.save(order); transaction.commit(); session.close(); sessionFactory.close(); ``` 我明明只执行了订单order的save操作,其中一个order对应多个ticket优惠券,为什么输出的sql中 是执行了对应的三个insert语句后,又执行了两次ticket优惠券的update?这里的update语句是干啥的,一对多级联保存机制是什么 ``` 这是打印的sql: Hibernate: insert into bc_order (orderName) values (?) Hibernate: insert into bc_ticket (ticketName, orderId) values (?, ?) Hibernate: insert into bc_ticket (ticketName, orderId) values (?, ?) Hibernate: update bc_ticket set orderId=?, p_index=? where ticketId=? Hibernate: update bc_ticket set orderId=?, p_index=? where ticketId=?

org.hibernate.TransientObjectException

[code]javax.servlet.ServletException: org.springframework.dao.InvalidDataAccessApiUsageException: com.entity.User; nested exception is org.hibernate.TransientObjectException: com.entity.User org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) com.util.FilterClass.doFilter(FilterClass.java:24) root cause org.springframework.dao.InvalidDataAccessApiUsageException: com.entity.User; nested exception is org.hibernate.TransientObjectException: com.entity.User org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:633) org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377) org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338) com.dao.daoimpl.BodycheckDaoImpl.adduserinfo(BodycheckDaoImpl.java:42) com.delegate.delegateimpl.BodycheckdelegateImpl.adduserinfo(BodycheckdelegateImpl.java:24) com.web.struts.action.BodyCheckAction.adduserinfo(BodyCheckAction.java:69) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270) org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) com.util.FilterClass.doFilter(FilterClass.java:24) root cause org.hibernate.TransientObjectException: com.entity.User org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216) org.hibernate.type.EntityType.getIdentifier(EntityType.java:108) org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221) org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476) org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803) org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467) org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190) org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113) org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195) org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76) org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26) org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985) org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390) org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373) org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338) com.dao.daoimpl.BodycheckDaoImpl.adduserinfo(BodycheckDaoImpl.java:42) com.delegate.delegateimpl.BodycheckdelegateImpl.adduserinfo(BodycheckdelegateImpl.java:24) com.web.struts.action.BodyCheckAction.adduserinfo(BodyCheckAction.java:69) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270) org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) javax.servlet.http.HttpServlet.service(HttpServlet.java:710) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) com.util.FilterClass.doFilter(FilterClass.java:24) [/code] 帮我看看呢 我是用spring管理Hibernian和struts的 是建立有关系的 [code] public Integer adduserinfo(final Userinfo userinfo) { Integer num=(Integer)this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session s)throws HibernateException,SQLException { return s.save(userinfo); } }); [/code] userinfo包含有user的信息。 我看了意思就是 userinfo 中的user 是transient状态的, 不知道该怎么解决 [b]问题补充:[/b] userinfo配置的是多对一, 只在userinfo中配置了private User user; user中没有关联userinfo [b]问题补充:[/b] 知道怎么回事了 update userinfo 之前 执行了[color=red]userinfo.setUser(new User()),[/color]此时的userinfo是persistent状态,而user属性是一个transient状态的对象,并且cascade为默认的"none"(如果是all那么会试图创建一个新的User对象),所以无法更新userinfo。 都是 spring 的 formbackingObject 惹的麻烦,害我debuge了一下午,希望大家不要再范类似错误了。

这俩异常是怎么回事啊,急急急。就是调用hibernate的save方法的时候报错

java.lang.reflect.UndeclaredThrowableException at com.sun.proxy.$Proxy335.save(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at com.sun.proxy.$Proxy336.save(Unknown Source) at com.jumbo.taobao.manager.TopShipCancelParseManagerImpl.copySalesOrder(TopShipCancelParseManagerImpl.java:568) at com.jumbo.taobao.manager.TopShipCancelParseManagerImpl.splitOrderAndRefund(TopShipCancelParseManagerImpl.java:482) at com.jumbo.taobao.manager.TopShipCancelParseManagerImpl.splitSalesOrderAndRefund(TopShipCancelParseManagerImpl.java:430) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at com.sun.proxy.$Proxy732.splitSalesOrderAndRefund(Unknown Source) at com.jumbo.ag.TestAg.tets(TestAg.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:292) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) 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:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at loxia.aspect.QueryInterceptor.invoke(QueryInterceptor.java:88) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) ... 55 more Caused by: org.hibernate.HibernateException: illegally attempted to associate a proxy with two open Sessions at org.hibernate.proxy.AbstractLazyInitializer.setSession(AbstractLazyInitializer.java:126) at org.hibernate.engine.StatefulPersistenceContext.reassociateProxy(StatefulPersistenceContext.java:572) at org.hibernate.engine.StatefulPersistenceContext.reassociateIfUninitializedProxy(StatefulPersistenceContext.java:532) at org.hibernate.event.def.ProxyVisitor.processEntity(ProxyVisitor.java:50) at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:127) at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:121) at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:78) at org.hibernate.event.def.AbstractSaveEventListener.visitCollectionsBeforeSave(AbstractSaveEventListener.java:391) at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:296) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:179) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:135) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:800) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:774) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:778) at loxia.dao.support.HibernateDaoServiceImpl.save(HibernateDaoServiceImpl.java:38) at loxia.dao.support.GenericEntityDaoWrapper.save(GenericEntityDaoWrapper.java:23) ... 62 more

Spring+Hibernate 在getCurrentSession的时候报错

以下是我的配置: spring-mvc.xml: ``` <!-- 加载配置文件 --> <context:property-placeholder location="WEB-INF/config/db.config.properties" /> <!-- 自动注入为bean --> <context:component-scan base-package="com.cherry.mall" /> <!-- 启动注解驱动的spring MVC功能,注册请求url和注解POJO类方法的映射 --> <mvc:annotation-driven> <!-- 返回json数据,@response使用 --> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 对模型视图名称的解析,在请求时模型视图名称添加前后缀 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/pages/" /> <property name="suffix" value=".jsp" /> </bean> <!--这里是对静态资源的映射 --> <!-- <mvc:resources mapping="/js/**" location="/resources/js/" /> <mvc:resources mapping="/css/**" location="/resources/css/" /> <mvc:resources mapping="/img/**" location="/resources/img/" /> --> ``` srping-hibernate: ``` <?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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"> <!-- 配置数据源 c3p0 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="${jdbc.driver}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 请求超时时间 --> <property name="checkoutTimeout" value="30000" /> <!-- 每60秒检查所有连接池中的空闲连接。默认值: 0,不检查 --> <property name="idleConnectionTestPeriod" value="30" /> <!-- 连接数据库连接池最大空闲时间 --> <property name="maxIdleTime" value="30" /> <!-- 连接池初始化连接数 --> <property name="initialPoolSize" value="5" /> <property name="minPoolSize" value="5" /> <property name="maxPoolSize" value="20" /> <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。默认值: 3 --> <property name="acquireIncrement" value="5" /> </bean> <!-- 配置hibernate的SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <!-- 注入数据源 相关信息看源码 --> <property name="dataSource" ref="dataSource" /> <!-- hibernate配置信息 --> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <!-- 开启二级缓存 ehcache --> <!-- <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop> <prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.cache.provider_configuration_file_resource_path} </prop> --> </props> </property> <!-- 扫描hibernate注解配置的entity --> <property name="packagesToScan" value="com.cherry.mall.**.model" /> </bean> <!-- mybatis配置 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="/WEB-INF/config/mybatis-config.xml"></property> <property name="mapperLocations" value="classpath*:com/cherry/mall/**/mapping/*.xml"></property> </bean> <!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置事务增强处理Bean,指定事务管理器 --> <tx:advice id="transactionAdvice" transaction-manager="transactionManager"> <!-- 配置详细事务处理语义 --> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="create*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="alter*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="get*" propagation="SUPPORTS" read-only="true" /> <tx:method name="query*" propagation="SUPPORTS" read-only="true" /> <tx:method name="find*" propagation="SUPPORTS" read-only="true" /> <tx:method name="select*" propagation="SUPPORTS" read-only="true" /> <tx:method name="load*" propagation="SUPPORTS" read-only="true" /> <!-- 其他采用默认事务方式 --> <tx:method name="*" /> </tx:attributes> </tx:advice> <!-- Spring aop事务管理 --> <aop:config> <!-- 配置切入点 --> <aop:pointcut id="transactionPointcut" expression="execution(* com.cherry.mall..*.service..*.*(..))" /> <!-- 指定在txAdvice切入点应用txAdvice事务增强处理 --> <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /> </aop:config> </beans> ``` 报错信息: ``` org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:134) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014) at com.cherry.mall.common.dao.CommonDAO.getHBSession(CommonDAO.java:29) at com.cherry.mall.common.dao.CommonDAO.create(CommonDAO.java:48) at com.cherry.mall.common.service.CommonServiceImpl.create(CommonServiceImpl.java:72) at com.cherry.mall.message.service.impl.MessageServiceImpl.create(MessageServiceImpl.java:30) at com.cherry.mall.message.service.impl.MessageServiceImpl.create(MessageServiceImpl.java:1) at com.cherry.mall.message.controller.MessageController.save(MessageController.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) ``` 报错地点: ![图片说明](https://img-ask.csdn.net/upload/201708/17/1502946641_931733.png) 求大神指教

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

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

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

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

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

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

和黑客斗争的 6 天!

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

Intellij IDEA 实用插件安利

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

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 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年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

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

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

百度工程师,获利10万,判刑3年!

所有一夜暴富的方法都写在刑法中,但总有人心存侥幸。这些年互联网犯罪高发,一些工程师高技术犯罪更是引发关注。这两天,一个百度运维工程师的案例传遍朋友圈。1...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

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

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

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

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

面试:第十六章:Java中级开发(16k)

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

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

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

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

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

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

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

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

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

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

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

实时更新:计算机编程语言排行榜—TIOBE世界编程语言排行榜(2020年6月份最新版)

内容导航: 1、TIOBE排行榜 2、总榜(2020年6月份) 3、本月前三名 3.1、C 3.2、Java 3.3、Python 4、学习路线图 5、参考地址 1、TIOBE排行榜 TIOBE排行榜是根据全世界互联网上有经验的程序员、课程和第三方厂商的数量,并使用搜索引擎(如Google、Bing、Yahoo!)以及Wikipedia、Amazon、YouTube统计出排名数据。

立即提问
相关内容推荐