关于@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true)

[code="java"]@Entity
@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true)
public class TestA {

private int id;
private String title;
private String content;
private Date date;

...........

}[/code]

[size=large]@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true) 我加了这条Annotation但是做实验更新的时候为什么还是把所有字段给更新了啊?[/size]

3个回答

对不起啊,hibernate基本没用过,之前的回答就下了个文档看了看。
刚看了下hibernate,我试了下,3.3.2版的,@org.hibernate.annotations.Entity(dynamicUpdate=true)这个可以部分更新。如果你全部更新了,你检查下是不是跨session的update。如果是跨session的,请用merge方法进行绑定,再更新。
建议使用HQL。
本人hibernate新手,见谅。

org.hibernate.annotations.Entity
文档的解释:
• dynamicInsert: allow dynamic SQL for inserts
• dynamicUpdate: allow dynamic SQL for updates

说明使用的是动态SQL,不是带问号的static SQL。
不知道你问的是什么意思。“所有字段给更新了”是指什么?

如果在同一个session中查出来 然后更新 会动态生成sql;
如果在一个session中查出数据,然后在另一个session更新,会全部update,因为hibernate不知道哪些是你改过的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
org.hibernate.MappingException问题?
八月 28, 2015 10:11:04 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.0.Final} 八月 28, 2015 10:11:04 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.20.Final} 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 八月 28, 2015 10:11:04 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: com/aliyun/house1848/hibernate/test/AdminInfo.hbm.xml 八月 28, 2015 10:11:04 下午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 八月 28, 2015 10:11:04 下午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!) 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [com.microsoft.sqlserver.jdbc.SQLServerDriver] at URL [jdbc:sqlserver://localhost:1433] 八月 28, 2015 10:11:04 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=sa, password=****} 八月 28, 2015 10:11:05 下午 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect 八月 28, 2015 10:11:05 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 八月 28, 2015 10:11:05 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory 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:389) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1799) at com.aliyun.house1848.hibernate.test.HibernateTest.main(HibernateTest.java:35) 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:506) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163) ... 4 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:422) at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135) ... 13 more Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for registDate in class com.aliyun.house1848.hibernate.test.AdminInfo 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) ... 18 more Exception in thread "main" java.lang.NullPointerException at com.aliyun.house1848.hibernate.test.HibernateTest.main(HibernateTest.java:40) ![图片说明](https://img-ask.csdn.net/upload/201508/28/1440772766_259070.png) 而且javassit.jar包也已经导入了。 这是什么错误?怎么修改呢?
有了Ehcache Annotations for Spring还需要配置org.hibernate.cache.EhCacheProvider吗?
问一个白痴问题。 有了Ehcache Annotations for Spring还需要配置org.hibernate.cache.EhCacheProvider吗?
关于hibernate3.3.1的annotations配置问题?
先帖代码吧 HibernateUtils.java [code="java"] package com; import org.apache.log4j.Logger; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.Session; public class HibernateUtils { private static final Logger logger = Logger.getLogger(HibernateUtils.class); private static final SessionFactory sessionFactory; static { try { //System.out.println(new AnnotationConfiguration().configure().buildSessionFactory()); sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); //sessionFactory = new AnnotationConfiguration().configure("/hibernate.cfg.xml").buildSessionFactory(); } catch (Exception e) { logger.error(e.getMessage()); throw new ExceptionInInitializerError(e); } } public static Session getSession() { return sessionFactory.openSession(); } } [/code] User.java [code="java"] package com; import javax.persistence.*; @Entity @Table(name="user") public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; private String name; private String password; private String email; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } [/code] MainClass.java [code="java"] package com; import org.hibernate.Session; import org.hibernate.Transaction; public class MainClass { /** * @param args */ public static void main(String[] args) { User user = new User(); user.setName("andy"); user.setPassword("123456"); user.setEmail("andy@123.com"); Session session = HibernateUtils.getSession(); Transaction tx = session.beginTransaction(); session.saveOrUpdate(user); tx.commit(); } } [/code] 执行的时候出现 Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager at com.HibernateUtils.<clinit>(HibernateUtils.java:17) at com.MainClass.main(MainClass.java:17) 错误,不知道怎么解决.第一个demo希望支持下
想参考springside实现Hibernate的零配置,但提示错误:org.hibernate.hql.ast.QuerySyntaxException
想参考Springside实现Hibernate的零配置文件,写了一个简单的测试用例,查询一张表(数据库表名为TB_USER,对应的实体类名为User),但是出错如下: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User] 错误提示是说我的“from User”语句中“User”未建立映射。在网上查过,类似的问题一般是因为类名的大小写错误或者配置文件错误,导致类名和数据库表名没有建立映射关系,但我似乎没有这类问题。好几天了找不到原因,不知道哪里的配置有毛病,以下是相关代码 测试用例如下: [code="java"] import org.springframework.beans.factory.annotation.Autowired; import org.springside.modules.test.junit38.SpringTransactionalTestCase; import accountant.entity.User; public class DaoTest extends SpringTransactionalTestCase { @Autowired org.springside.modules.orm.hibernate.HibernateDao<User, Long> dao ; //列出所有User表记录 public void testUserList() { //试过把完整包名带上,写成“from accountant.entity.User”,还是一样的错误 dao.find("from User", null); } } [/code] User类代码如下,其中@Table(name="TB_USER")指明对应的数据库表是“TB_USER”,这张表在库中确定存在,并有两条记录 [code="java"] package accountant.entity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; @Entity @Table(name="TB_USER") public class User { String name; String id; String sex; String address; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } } [/code] applicationContext.xml中的数据库相关配置如下,其中 “<property name="packagesToScan" value="accountant.entity.*" />”是指定自动扫描实体类的包,User类也就在“accountant.entity”这个包下 [code="java"] <!-- 数据源配置,使用应用内的DBCP数据库连接池。--> <!--这里数据库的连接应该是没问题的,因为出错时提示的是Hql执行错误,说明数据库连接已经成功建立了,不过是执行的语句有问题 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <!-- Connection Info --> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- Connection Pooling DBCP --> <property name="initialSize" value="5" /> <property name="maxActive" value="100" /> <property name="maxIdle" value="30" /> <property name="maxWait" value="1000" /> <property name="poolPreparedStatements" value="true" /> <property name="defaultAutoCommit" value="false" /> </bean> <!-- Hibernate配置--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="namingStrategy"> <bean class="org.hibernate.cfg.ImprovedNamingStrategy" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9iDialect</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider </prop> </props> </property> <property name="packagesToScan" value="accountant.entity.*" /> </bean> <!-- Dao类 --> <bean id="hibernateDao" class="org.springside.modules.orm.hibernate.HibernateDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> [/code] 相关的代码就是以上三处,不知道哪里有遗漏或是错误,请指点一二,非常感谢! [b]问题补充:[/b] [code="java"][/code] 先谢谢二位,我的spring和hibernate的jar版本如下: [img]/upload/attachment/124016/5a67b24b-27e0-348a-ab6f-5d7003972509.gif[/img] [img]/upload/attachment/124018/751e247e-4c6c-341f-9859-4a52863af90d.gif[/img] 这个小例子是在springside的mini-web范例上直接改的,应该环境方面不会有大问题吧 to layer555: springside的mini-web的applicationContext.xml是这样的: [code="java"] <?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" default-lazy-init="true"> <description>Spring公共配置文件 </description> <!-- 定义受环境影响易变的变量 --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> <property name="ignoreResourceNotFound" value="true" /> <property name="locations"> <list> <!-- 标准配置 --> <value>classpath*:/application.properties</value> <!-- 本地开发环境配置 --> <value>classpath*:/application.local.properties</value> <!-- 服务器生产环境配置 --> <!-- <value>file:/var/myapp/application.server.properties</value> --> </list> </property> </bean> <!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 --> <context:component-scan base-package="org.springside.examples.miniweb" /> <!-- 数据源配置,使用应用内的DBCP数据库连接池 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <!-- Connection Info --> <property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- Connection Pooling DBCP --> <property name="initialSize" value="5" /> <property name="maxActive" value="100" /> <property name="maxIdle" value="30" /> <property name="maxWait" value="1000" /> <property name="poolPreparedStatements" value="true" /> <property name="defaultAutoCommit" value="false" /> </bean> <!-- 数据源配置,使用应用服务器的数据库连接池 --> <!--<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/ExampleDB" />--> <!-- Hibernate配置 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="namingStrategy"> <bean class="org.hibernate.cfg.ImprovedNamingStrategy" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider </prop> <prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.ehcache_config_file}</prop> </props> </property> <property name="packagesToScan" value="org.springside.examples.miniweb.entity.*" /> </bean> <!-- 事务管理器配置,单数据源事务 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 事务管理器配置,多数据源JTA事务--> <!-- <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager or WebLogicJtaTransactionManager" /> --> <!-- 使用annotation定义事务 --> <tx:annotation-driven transaction-manager="transactionManager" /> </beans> [/code] 这里面也没有configurationClass,也能正常,不知道在什么地方设置或默认了 to xuzhfa123: 改了你说的两处,确实可以跑通了,非常感谢。但搞不明白的是,在上面贴的mini-web的配置文件中是这么写的: [code="java"]<property name="packagesToScan" value="org.springside.examples.miniweb.entity.*" /> [/code] 这个例子是可以正常运行的,为什么我就必须改成 [code="java"] <property name="packagesToScan" value="accountant.entity" /> [/code] 才可以呢?
org.hibernate.InvalidMappingException: Could not parse mapping document from
<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p>照网上方法,试了很多,但仍解决不了。</p> <p>=========================================================================================================</p> <p>12:01:14,672  INFO Version:37 - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}</p> <p>12:01:14,721  INFO Version:41 - HHH000412: Hibernate Core {4.1.10.Final}</p> <p>12:01:14,731  INFO Environment:239 - HHH000206: hibernate.properties not found</p> <p>12:01:14,734  INFO Environment:342 - HHH000021: Bytecode provider name : javassist</p> <p>12:01:14,783  INFO Configuration:1926 - HHH000043: Configuring from resource: /hibernate.cfg.xml</p> <p>12:01:14,784  INFO Configuration:1945 - HHH000040: Configuration resource: /hibernate.cfg.xml</p> <p>12:01:15,199  INFO Configuration:718 - HHH000221: Reading mappings from resource: cn/jhost/alibaba/user/vo/UserModel.hbm.xml</p> <p>12:01:15,522  INFO Configuration:2067 - HHH000041: Configured SessionFactory: null</p> <p>org.hibernate.InvalidMappingException: Could not parse mapping document from resource cn/jhost/alibaba/user/vo/UserModel.hbm.xml</p> <p>at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3423)</p> <p>at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3412)</p> <p>at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3400)</p> <p>at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1330)</p> <p>at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1730)</p> <p>at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781)</p> <p>at cn.jhost.alibaba.common.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:13)</p> <p>at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:68)</p> <p>at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:1)</p> <p>at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:22)</p> <p>at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:1)</p> <p>at cn.jhost.alibaba.user.business.factory.UserEbiFactory.main(UserEbiFactory.java:20)</p> <p>Caused by: org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModel</p> <p>at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:182)</p> <p>at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:174)</p> <p>at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:197)</p> <p>at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:253)</p> <p>at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)</p> <p>at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:324)</p> <p>at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2311)</p> <p>at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2276)</p> <p>at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2166)</p> <p>at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:407)</p> <p>at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:322)</p> <p>at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:173)</p> <p>at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3420)</p> <p>... 11 more</p> <p>Exception in thread "main" java.lang.NullPointerException</p> <p>at cn.jhost.alibaba.common.HibernateUtil.currentSession(HibernateUtil.java:26)</p> <p>at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:68)</p> <p>at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:1)</p> <p>at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:22)</p> <p>at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:1)</p> <p>at cn.jhost.alibaba.user.business.factory.UserEbiFactory.main(UserEbiFactory.java:20)</p> <p>===============================================================================================</p> <p>&lt;?xml version="1.0" encoding='utf-8'?&gt;</p> <p>&lt;!DOCTYPE hibernate-mapping PUBLIC </p> <p>"-//Hibernate/Hibernate Mapping DTD 3.0//EN"</p> <p>"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;</p> <p> </p> <p>&lt;hibernate-mapping&gt;</p> <p> </p> <p>    &lt;class name="cn.jhost.alibaba.user.vo.UserModel" table="tbl_user"  dynamic-insert="true" dynamic-update="true" optimistic-lock="version"&gt;</p> <p>    &lt;id name="uuid"&gt;</p> <p>    &lt;generator class="uuid"/&gt;</p> <p>    &lt;/id&gt;</p> <p>    &lt;version name="version" column="version"/&gt;</p> <p>    &lt;property name="name" column="name" /&gt;</p> <p>    &lt;property name="password" column="password"/&gt;</p> <p>&lt;property name="type" column="type"/&gt;</p> <p> </p> <p>&lt;/class&gt;</p> <p> </p> <p>&lt;/hibernate-mapping&gt;</p> <p>====================================================================================</p> <p>&lt;?xml version='1.0' encoding='utf-8'?&gt;</p> <p>&lt;!DOCTYPE hibernate-configuration PUBLIC</p> <p>"-//Hibernate/Hibernate Configuration DTD 3.0//EN"</p> <p>"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;</p> <p> </p> <p>&lt;hibernate-configuration&gt;</p> <p> </p> <p>    &lt;session-factory&gt;</p> <p> </p> <p>        &lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;</p> <p>        &lt;property name="connection.url"&gt;jdbc:mysql://localhost:3306/alibaba?useUnicode=true&amp;amp;characterEncoding=UTF-8&lt;/property&gt;</p> <p>        &lt;property name="connection.username"&gt;root&lt;/property&gt;</p> <p>        &lt;property name="connection.password"&gt;123456&lt;/property&gt;</p> <p> </p> <p>&lt;property name="c3p0.min_size"&gt;5&lt;/property&gt;</p> <p>        &lt;property name="c3p0.max_size"&gt;20&lt;/property&gt;</p> <p>        &lt;property name="c3p0.timeout"&gt;180&lt;/property&gt;</p> <p>        &lt;property name="c3p0.max_statements"&gt;5&lt;/property&gt;</p> <p>        </p> <p>        &lt;property name="dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;</p> <p> </p> <p>        &lt;!-- Enable Hibernate's automatic session context management --&gt;</p> <p>        &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;</p> <p> </p> <p>        &lt;property name="show_sql"&gt;true&lt;/property&gt;</p> <p>&lt;property name="format_sql"&gt;true&lt;/property&gt;</p> <p> </p> <p> </p> <p>        &lt;mapping resource="cn/jhost/alibaba/user/vo/UserModel.hbm.xml"/&gt;</p> <p> </p> <p>    &lt;/session-factory&gt;</p> <p> </p> <p>&lt;/hibernate-configuration&gt;</p> </div>
juit测试ssh时总是出现下面的红色字体,虽然不影响,但是怎么能不让他显示出来
2016-6-22 21:46:26 org.hibernate.annotations.common.Version <clinit> 信息: Hibernate Commons Annotations 3.2.0.Final 2016-6-22 21:46:26 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.6.0.Final 2016-6-22 21:46:26 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2016-6-22 21:46:26 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : javassist 2016-6-22 21:46:26 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2016-6-22 21:46:26 org.hibernate.util.DTDEntityResolver resolveEntity 警告: recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 2016-6-22 21:46:26 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues 信息: Mapping class: cn.itcast.test.entity.Person -> person 2016-6-22 21:46:26 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL 信息: Hibernate Validator not found: ignoring 2016-6-22 21:46:26 org.hibernate.cfg.search.HibernateSearchEventListenerRegister enableHibernateSearch 信息: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 2016-6-22 21:46:26 org.hibernate.connection.ConnectionProviderFactory initializeConnectionProviderFromConfig 信息: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 2016-6-22 21:46:27 org.hibernate.dialect.Dialect <init> 信息: Using dialect: org.hibernate.dialect.MySQL5Dialect 2016-6-22 21:46:27 org.hibernate.engine.jdbc.JdbcSupportLoader useContextualLobCreation 信息: Disabling contextual LOB creation as connection was null 2016-6-22 21:46:27 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory 信息: Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory 2016-6-22 21:46:27 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup 信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic flush during beforeCompletion(): disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic session close at end of transaction: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Scrollable result sets: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC3 getGeneratedKeys(): disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Connection release mode: auto 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Maximum outer join fetch depth: 2 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default batch fetch size: 1 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Generate SQL with comments: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL updates by primary key: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL inserts for batching: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory 信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2016-6-22 21:46:27 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> 信息: Using ASTQueryTranslatorFactory 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {} 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: JPA-QL strict compliance: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Second-level cache: enabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query cache: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory createRegionFactory 信息: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Structured second-level cache entries: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Echoing all SQL to stdout 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Statistics: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Deleted entity synthetic identifier rollback: disabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default entity-mode: pojo 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Named query checking : enabled 2016-6-22 21:46:27 org.hibernate.cfg.SettingsFactory buildSettings 信息: Check Nullability in Core (should be disabled when Bean Validation is on): disabled 2016-6-22 21:46:27 org.hibernate.impl.SessionFactoryImpl <init> 信息: building session factory 2016-6-22 21:46:27 org.hibernate.id.UUIDHexGenerator <init> 警告: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead 2016-6-22 21:46:27 org.hibernate.impl.SessionFactoryObjectFactory addInstance 信息: Not binding factory to JNDI, no JNDI name configured 2016-6-22 21:46:27 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: Running hbm2ddl schema update 2016-6-22 21:46:27 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: fetching database metadata 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: updating schema 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: table found: itcastTax.person 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: columns: [id, name] 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: foreign keys: [] 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: indexes: [primary] 2016-6-22 21:46:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: schema update complete
ssh环境配置问题总是出现警告信息 数据库可以操作成功警告信息怎么去掉
2016-10-31 18:59:28 org.hibernate.annotations.common.Version <clinit> 信息: Hibernate Commons Annotations 3.2.0.Final 2016-10-31 18:59:28 org.hibernate.cfg.Environment <clinit> 信息: Hibernate 3.6.0.Final 2016-10-31 18:59:28 org.hibernate.cfg.Environment <clinit> 信息: hibernate.properties not found 2016-10-31 18:59:28 org.hibernate.cfg.Environment buildBytecodeProvider 信息: Bytecode provider name : javassist 2016-10-31 18:59:28 org.hibernate.cfg.Environment <clinit> 信息: using JDK 1.4 java.sql.Timestamp handling 2016-10-31 18:59:28 org.hibernate.util.DTDEntityResolver resolveEntity 警告: recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 2016-10-31 18:59:28 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues 信息: Mapping class: cn.itcast.test.entity.Person -> person 2016-10-31 18:59:28 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL 信息: Hibernate Validator not found: ignoring 2016-10-31 18:59:28 org.hibernate.cfg.search.HibernateSearchEventListenerRegister enableHibernateSearch 信息: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 2016-10-31 18:59:28 org.hibernate.connection.ConnectionProviderFactory initializeConnectionProviderFromConfig 信息: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Database -> name : MySQL version : 5.5.40 major : 5 minor : 5 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Driver -> name : MySQL-AB JDBC Driver version : mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} ) major : 5 minor : 1 2016-10-31 18:59:28 org.hibernate.dialect.Dialect <init> 信息: Using dialect: org.hibernate.dialect.MySQL5Dialect 2016-10-31 18:59:28 org.hibernate.engine.jdbc.JdbcSupportLoader useContextualLobCreation 信息: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 2016-10-31 18:59:28 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory 信息: Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory 2016-10-31 18:59:28 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup 信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic flush during beforeCompletion(): disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Automatic session close at end of transaction: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC batch size: 15 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC batch updates for versioned data: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Scrollable result sets: enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JDBC3 getGeneratedKeys(): enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Connection release mode: auto 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Maximum outer join fetch depth: 2 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default batch fetch size: 1 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Generate SQL with comments: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL updates by primary key: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Order SQL inserts for batching: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory 信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2016-10-31 18:59:28 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> 信息: Using ASTQueryTranslatorFactory 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query language substitutions: {} 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: JPA-QL strict compliance: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Second-level cache: enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Query cache: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory createRegionFactory 信息: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Optimize cache for minimal puts: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Structured second-level cache entries: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Echoing all SQL to stdout 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Statistics: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Deleted entity synthetic identifier rollback: disabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Default entity-mode: pojo 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Named query checking : enabled 2016-10-31 18:59:28 org.hibernate.cfg.SettingsFactory buildSettings 信息: Check Nullability in Core (should be disabled when Bean Validation is on): disabled 2016-10-31 18:59:28 org.hibernate.impl.SessionFactoryImpl <init> 信息: building session factory 2016-10-31 18:59:28 org.hibernate.id.UUIDHexGenerator <init> 警告: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead 2016-10-31 18:59:29 org.hibernate.impl.SessionFactoryObjectFactory addInstance 信息: Not binding factory to JNDI, no JNDI name configured 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: Running hbm2ddl schema update 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: fetching database metadata 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: updating schema 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: table found: day17.person 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: columns: [id, name] 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: foreign keys: [] 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.TableMetadata <init> 信息: indexes: [primary] 2016-10-31 18:59:29 org.hibernate.tool.hbm2ddl.SchemaUpdate execute 信息: schema update complete Hibernate: insert into person (name, id) values (?, ?)
hibernate4.3报错是怎么回事?
2016-10-6 11:01:28 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final} 2016-10-6 11:01:28 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.3.11.Final} 2016-10-6 11:01:28 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 2016-10-6 11:01:28 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 2016-10-6 11:01:28 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 2016-10-6 11:01:28 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 2016-10-6 11:01:28 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: com/zpp/pojo/User.hbm.xml 2016-10-6 11:01:29 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 2016-10-6 11:01:29 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!) 2016-10-6 11:01:29 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hibernate4] 2016-10-6 11:01:29 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000046: Connection properties: {user=root, password=****} 2016-10-6 11:01:29 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000006: Autocommit mode: false 2016-10-6 11:01:29 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 (min=1) 2016-10-6 11:01:29 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 2016-10-6 11:01:29 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 2016-10-6 11:01:29 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 2016-10-6 11:01:29 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory
BeanCreationException
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean; at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:586) at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1750) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.annotations.reflection.XMLContext$Default.getDelimitedIdentifier()Ljava/lang/Boolean; at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:90) at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:252) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1388) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1930) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:372) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:454) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:439) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570) ... 25 more
刚开始学习hibernate 遇到不懂的请问一下 这里是哪里有错误 错误是怎么看的 谢谢
二月 10, 2017 6:57:50 下午 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 二月 10, 2017 6:57:50 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.4.Final} 二月 10, 2017 6:57:50 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 二月 10, 2017 6:57:50 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 二月 10, 2017 6:57:50 下午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 二月 10, 2017 6:57:50 下午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
新手Hibernate写了个小程序,第一次运行报错如下,好像还有数据库连不上的问题,不知道该怎么改
九月 07, 2015 10:31:46 下午 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} 九月 07, 2015 10:31:46 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.1.4.Final} 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: com/xdc/Product/Product.hbm.xml 九月 07, 2015 10:31:46 下午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!) 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000148: No JDBC Driver class was specified by property hibernate.connection.driver_class 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [null] at URL [jdbc:mysql://localhost:3306/db_database10] 九月 07, 2015 10:31:46 下午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=root, password=****} 九月 07, 2015 10:31:46 下午 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure WARN: HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:mysql://localhost:3306/db_database10 九月 07, 2015 10:31:46 下午 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 九月 07, 2015 10:31:46 下午 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000422: Disabling contextual LOB creation as connection was null 九月 07, 2015 10:31:46 下午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 九月 07, 2015 10:31:46 下午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory 九月 07, 2015 10:31:46 下午 org.hibernate.validator.util.Version <clinit> 信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2 九月 07, 2015 10:31:46 下午 org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA 信息: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. 九月 07, 2015 10:31:46 下午 org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA 信息: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver. 九月 07, 2015 10:31:47 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 0, SQLState: 08001 九月 07, 2015 10:31:47 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: No suitable driver found for jdbc:mysql://localhost:3306/db_database10 添加数据库失败! org.hibernate.exception.JDBCConnectionException: Could not open connection at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160) at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396) at com.xdc.main.AddProduct.main(AddProduct.java:19) Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/db_database10 at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:187) at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193) at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281) at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297) ... 5 more 配置如下 <hibernate-configuration> <session-factory> <!-- 数据库驱动 --> <property name="connect.driver_class"> com.mysql.jdbc.Driver </property> <!-- 数据库连接的URL --> <property name="connection.url"> jdbc:mysql://localhost:3306/db_database10 </property> <!-- 数据库连接用户名 --> <property name="connection.username">root</property> <!-- 数据库连接密码 --> <property name="connection.password">123321</property> <!-- Hibernate方言 --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 打印sql语句 --> <property name="show_sql">true</property> <!-- 映射文件 --> <mapping resource="com/xdc/Product/Product.hbm.xml" /> </session-factory> </hibernate-configuration>
在eclipse中运行Hibernate,出现Autocommit mode: false错误
我的Hibernate版本是:5.2.2以下是代码与错误提示 no1 一月 13, 2017 9:25:47 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.2.2.Final} 一月 13, 2017 9:25:47 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 一月 13, 2017 9:25:47 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist no2 一月 13, 2017 9:25:47 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 一月 13, 2017 9:25:47 下午 org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-mapping. Use namespace http://www.hibernate.org/dtd/hibernate-mapping instead. Support for obsolete DTD/XSD namespaces may be removed at any time. 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql:///testhibernate] 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {user=root, password=****} 一月 13, 2017 9:25:48 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.internal.CoreMessageLogger.debugf(Ljava/lang/String;I)V at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:36) at org.hibernate.engine.jdbc.connections.internal.PooledConnections.<init>(PooledConnections.java:20) at org.hibernate.engine.jdbc.connections.internal.PooledConnections$Builder.build(PooledConnections.java:161) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:109) at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:72) at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:240) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:145) at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) 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:257) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:231) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) 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:240) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) 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.boot.MetadataSources.buildMetadata(MetadataSources.java:179) at com.hibernate.test1.test.main(test.java:17) --------------------------------------------------------------- <?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.jdbc.Driver</property> <property name="connection.url">jdbc:mysql:///testhibernate</property> <property name="connection.username">root</property> <property name="connection.password">root</property> <!-- <property name="dialect">org.hibernate.dialect.MySQLDialect</property> --> <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="hbm2ddl.auto">update</property> <property name="show_sql">true</property> <mapping resource="com/hibernate/bean/LoginBean.hbm.xml"/> </session-factory> </hibernate-configuration> ----------------------------------------------------------- package com.hibernate.test1; 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; public class test { public static void main(String[] args) { // TODO Auto-generated method stub StandardServiceRegistry registry=new StandardServiceRegistryBuilder().configure().build(); SessionFactory sessionfactory=new MetadataSources(registry).buildMetadata().buildSessionFactory(); Session session=sessionfactory.openSession(); Transaction transaction=session.beginTransaction(); log log1=new log(); log1.setName("nihao"); log1.setPass("dkjk"); session.save(log1); transaction.commit(); } } ----------------------------------------------- <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated 2017-1-13 18:13:48 by Hibernate Tools 3.5.0.Final --> <hibernate-mapping> <class name="com.hibernate.test.log" table="LOG"> <id name="name" type="java.lang.String"> <column name="NAME" /> <generator class="assigned" /> </id> <property name="pass" type="java.lang.String"> <column name="PASS" /> </property> </class> </hibernate-mapping>
SchemaExport export自动创建表失败
package entity; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.tool.hbm2ddl.SchemaExport; import org.junit.Test; public class TestStudents { @Test public void testSchemaExport() { //创建配置对象 Configuration config = new Configuration().configure(); //创建服务注册对象 ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry(); //创建sessionFactory SessionFactory sessionFactory = config.buildSessionFactory(serviceRegistry); //创建session对象 Session session = sessionFactory.getCurrentSession(); //创建SchemaExport对象 SchemaExport export = new SchemaExport(config); export.create(true, true); } } 九月 20, 2015 2:40:45 上午 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 九月 20, 2015 2:40:46 上午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.4.Final} 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: entity/Students.hbm.xml 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: entity/Users.hbm.xml 九月 20, 2015 2:40:46 上午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!) 九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: false 九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql:///test?useUnicode=true&characterEncoding=UTF-8] 九月 20, 2015 2:40:46 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=root, password=****} 九月 20, 2015 2:40:46 上午 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure WARN: HHH000342: Could not obtain connection to query metadata : Access denied for user 'root'@'localhost' (using password: NO) 九月 20, 2015 2:40:46 上午 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 九月 20, 2015 2:40:46 上午 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000422: Disabling contextual LOB creation as connection was null 九月 20, 2015 2:40:46 上午 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 九月 20, 2015 2:40:46 上午 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory
org.hibernate.HibernateException: No Session found for current thread
hibernate4.2 spring3.2.2 工程启动没错,执行方法报如下错误: 严重: Servlet.service() for servlet spring3mvc threw exception org.hibernate.HibernateException: No Session found for current thread at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97) at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:980) at com.xp.common.dao.BaseHibernateDao.getSession(BaseHibernateDao.java:26) at com.xp.common.dao.BaseHibernateDao.saveOrUpdate(BaseHibernateDao.java:48) at com.xp.dao.UserLoginDao.saveUser(UserLoginDao.java:16) at com.xp.service.UserLoginService.saveUser(UserLoginService.java:23) at com.xp.web.UserLoginController.saveUser(UserLoginController.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) .... -------------------------- web.xml [code="java"] <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>spring</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext-hibernate.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <servlet> <servlet-name>spring3mvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring3mvc</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> </web-app> [/code] spring3mvc-servlet.xml [code="java"] <?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd" default-lazy-init="true"> <!-- 启用spring mvc 注解 --> <context:annotation-config /> <!--使Spring支持自动检测组件,如注解的Controller --> <context:component-scan base-package="com.xp.web" /> <mvc:default-servlet-handler/> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/" p:suffix=".jsp" /> <!-- 上传配置 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="UTF-8" /> <property name="maxUploadSize" value="2147483648" /> <!-- 2G --> </bean> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="order" value="0"></property> </bean> <!-- 启动 Spring MVC 的注解功能,完成请求和注解 POJO 的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.StringHttpMessageConverter" /> </list> </property> </bean> <!-- 扫描并自动装配 --> <context:component-scan base-package="com.xp.dao" /> <context:component-scan base-package="com.xp.service" /> </beans> [/code] applicationContext-hibernate.xml [code="java"] <?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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-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/mvc http://www.springframework.org/schema/mvc/spring-mvc-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/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd" default-lazy-init="true"> <bean id="druid_dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="jdbc:mysql://127.0.0.1:3306/spring" /> <property name="username" value="root" /> <property name="password" value="123456" /> <property name="maxActive" value="20" /> <property name="validationQuery" value="SELECT 'x'" /> <property name="testWhileIdle" value="true" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="druid_dataSource" /> <property name="packagesToScan" value="com.xp.model*"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="show_sql">true</prop> <prop key="hibernate.jdbc.batch_size">20</prop> <!-- <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate3.SpringSessionContext</prop> --> </props> </property> </bean> <!-- 开启注解事务 只对当前配置文件有效 --> <tx:annotation-driven transaction-manager="txManager"/> <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="create*" propagation="REQUIRED" /> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="merge*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="put*" propagation="REQUIRED" /> <tx:method name="use*" propagation="REQUIRED"/> <!--hibernate4必须配置为开启事务 否则 getCurrentSession()获取不到--> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="count*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="list*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <aop:config expose-proxy="true"> <!-- 只对业务逻辑层实施事务 --> <aop:pointcut id="txPointcut" expression="execution(* com.xp.dao..*.*(..)) OR execution(* com.xp.common..*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/> </aop:config> </beans> [/code] dao层代码: [code="java"] BaseHibernateDao.java -------------------------- @Resource(name = "sessionFactory") private SessionFactory sessionFactory; public Session getSession() { return sessionFactory.getCurrentSession(); } @SuppressWarnings("unchecked") @Override public <T, PK extends Serializable> T get(Class<T> model, PK id) { return (T)getSession().get(model, id); } @Override public <T> T save(T model) { getSession().save(model); return model; } UserLoginDao.java -------------------------- public void saveUser(User user) { this.saveOrUpdate(user); } [/code] 需导入的包如下: antlr-2.7.7.jar aopalliance-1.0.jar aspectjrt.jar aspectjweaver.jar commons-fileupload-1.3.jar commons-logging-1.1.2.jar dom4j-1.6.1.jar druid-0.2.12.jar hibernate-commons-annotations-4.0.1.Final.jar hibernate-core-4.2.0.Final.jar hibernate-jpa-2.0-api-1.0.1.Final.jar javassist-3.15.0-GA.jar jboss-logging-3.1.0.GA.jar jta-1.1.jar mysql-connector-java-5.1.21.jar spring-aop-3.2.2.RELEASE.jar spring-aspects-3.2.2.RELEASE.jar spring-beans-3.2.2.RELEASE.jar spring-context-3.2.2.RELEASE.jar spring-core-3.2.2.RELEASE.jar spring-expression-3.2.2.RELEASE.jar spring-orm-3.2.2.RELEASE.jar spring-tx-3.2.2.RELEASE.jar spring-web-3.2.2.RELEASE.jar spring-webmvc-3.2.2.RELEASE.jar
hibernate运行总是出错 求解答
一直出错困扰我两天了 求大家帮忙解决一下 谢谢了 一月 18, 2016 11:10:26 下午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.0.7.Final} 一月 18, 2016 11:10:26 下午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 一月 18, 2016 11:10:26 下午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 一月 18, 2016 11:10:26 下午 org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead. Support for obsolete DTD/XSD namespaces may be removed at any time. 一月 18, 2016 11:10:26 下午 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 一月 18, 2016 11:10:27 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) 一月 18, 2016 11:10:27 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/hibernate] 一月 18, 2016 11:10:27 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {user=root, password=****} 一月 18, 2016 11:10:27 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false 一月 18, 2016 11:10:27 下午 org.hibernate.engine.jdbc.connections.internal.PooledConnections <init> INFO: HHH000115: Hibernate connection pool size: 1 (min=1) 一月 18, 2016 11:10:27 下午 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 一月 18, 2016 11:10:27 下午 org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 一月 18, 2016 11:10:28 下午 org.hibernate.tool.hbm2ddl.SchemaExport execute INFO: HHH000227: Running hbm2ddl schema export 一月 18, 2016 11:10:28 下午 org.hibernate.tool.hbm2ddl.SchemaExport execute INFO: HHH000230: Schema export complete org.hibernate.MappingException: Unknown entity: com.hi.Students 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.cat.StudentsTest.testSaveStudents(StudentsTest.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) 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.junit.runners.ParentRunner.run(ParentRunner.java:300) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 一月 18, 2016 11:10:28 下午 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql://localhost/hibernate] hibernate.cfg.xml <?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> <session-factory> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost/hibernate</property> <property name="connection.username">root</property> <property name="connection.password">mona</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="connection.pool_size">1</property> <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="hbm2ddl.auto">create</property> <mapping resource="com/hi/Students.hbm.xml"/> </session-factory> </hibernate-configuration> Students.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 package="com.hi"> <class name="com.hi.Students" table="STUDENTS"> <id name="id" type="int"> <column name="ID" /> <generator class="assigned" /> </id> <property name="name" type="java.lang.String"> <column name="NAME" /> </property> <property name="age" type="int"> <column name="AGE" /> </property> </class> </hibernate-mapping> Student.java package com.hi; //学生类 public class Students { private int id; private String name; private int age; public Students() { } public Students(int id, String name, int age) { this.id = id; this.name = name; this.age = age; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "Students [id=" + id + ", name=" + name + ", age=" + age + "]"; } } StudentsTest.java package com.cat; 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 org.junit.After; import org.junit.Before; import org.junit.Test; import com.hi.Students; public class StudentsTest { private SessionFactory sessionFactory; private Session session; private Transaction transaction; @Before public void init(){ Configuration config = new Configuration().configure(); ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); sessionFactory = config.buildSessionFactory(serviceRegistry); session = sessionFactory.openSession(); transaction = session.beginTransaction(); } @After public void destory(){ transaction.commit(); session.close(); sessionFactory.close(); } @Test public void testSaveStudents(){ Students s = new Students(1, "张三丰", 15); session.save(s); } }
求帮我看看hibernate的问题
2016-4-30 13:01:01 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 2016-4-30 13:01:01 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.4.Final} 2016-4-30 13:01:01 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 2016-4-30 13:01:01 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 2016-4-30 13:01:01 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 2016-4-30 13:01:01 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 2016-4-30 13:01:01 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 2016-4-30 13:01:01 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: Teachers/hbm.xml 这是我模仿例子然后报错的信息,能不能帮我看看哪里有问题的
怎么回事,Hibernate这样也能成功,但这么多警告,怎么回事?
<font color="red">2015-7-14 20:58:10 org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final} 2015-7-14 20:58:10 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.3.10.Final} 2015-7-14 20:58:10 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 2015-7-14 20:58:10 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 2015-7-14 20:58:10 org.hibernate.cfg.Configuration configure INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml 2015-7-14 20:58:10 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: HHH000040: Configuration resource: /hibernate.cfg.xml 2015-7-14 20:58:10 org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: org/yang/model/Student.hbm.xml 2015-7-14 20:58:10 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 2015-7-14 20:58:10 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!) 2015-7-14 20:58:10 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/hibernate] 2015-7-14 20:58:10 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000046: Connection properties: {user=root, password=****} 2015-7-14 20:58:10 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH000006: Autocommit mode: false 2015-7-14 20:58:10 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 (min=1) 2015-7-14 20:58:10 org.hibernate.dialect.Dialect <init> INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 2015-7-14 20:58:10 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 2015-7-14 20:58:10 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService INFO: HHH000399: Using default transaction strategy (direct JDBC transactions) 2015-7-14 20:58:10 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> INFO: HHH000397: Using ASTQueryTranslatorFactory</font> Hibernate: insert into student (name, age, id) values (?, ?, ?) <font color="red">2015-7-14 20:58:11 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop INFO: HHH000030: Cleaning up connection pool [jdbc:mysql://localhost:3306/hibernate]</font>
hibernate查询翻译器找不到相应的类
有对应的jar文件,jboss-transaction-api_1.1_spec-1.0.1.Final、jboss-logging-3.1.0.GA、javassist-3.18.1-GA、hibernate-jpa-2.0-api-1.0.1.Final、hibernate-core-4.2.17.Final、hibernate-commons-annotations-4.0.2.Final、dom4j-1.6.1、antlr-2.7.7。在.cfg.xml文件中配置有<property name="hibernate.query.factory_class">org.hibernate.hql.ast.HqlToken</property> 但运行后还报错 Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.hql.ast.ASTQueryTranslatorFactory] at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:151) at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:586) ... 94 more Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.hql.ast.ASTQueryTranslatorFactory at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:318) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:148) ... 95 more
Hibernate4创建SessionFactory时卡住不运行?
Hibernate4创建SessionFactory时卡住不运行? 使用Hibernate4写一个CRUD示例,javase程序,在main方法中创建sessionFactory,使用如下代码: private HibernateUtils() { try { if (this.sessionFactory == null) { Configuration cfg = new Configuration(); cfg.configure(new File("hibernate.cfg.xml")); cfg.setNamingStrategy(ImprovedNamingStrategy.INSTANCE); ServiceRegistry sr =new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry(); this.sessionFactory = cfg.addAnnotatedClass(ApplyInfo.class) .addAnnotatedClass(Contract.class) .addAnnotatedClass(Overview.class) .addAnnotatedClass(SegmentHtml.class) .buildSessionFactory(sr); } } catch (Exception e) { e.printStackTrace(); throw e; } } 在Eclipse中普通运行就会卡住不允许,如果是debug方式运行,就没有任何问题. 卡在如下日志处 五月 13, 2014 10:34:16 上午 org.hibernate.annotations.common.Version <clinit> INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} 五月 13, 2014 10:34:16 上午 org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.12.Final} 五月 13, 2014 10:34:16 上午 org.hibernate.cfg.Environment <clinit> INFO: HHH000206: hibernate.properties not found 五月 13, 2014 10:34:16 上午 org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist 五月 13, 2014 10:34:16 上午 org.hibernate.cfg.Configuration configure INFO: HHH000042: Configuring from file: hibernate.cfg.xml 五月 13, 2014 10:34:17 上午 org.hibernate.cfg.Configuration doConfigure INFO: HHH000041: Configured SessionFactory: null 五月 13, 2014 10:34:17 上午 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator getConfiguredConnectionProviderName WARN: HHH000208: org.hibernate.connection.C3P0ConnectionProvider has been deprecated in favor of org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider; that provider will be used instead. 五月 13, 2014 10:34:17 上午 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator instantiateExplicitConnectionProvider INFO: HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider 五月 13, 2014 10:34:17 上午 org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure INFO: HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/pgdata 五月 13, 2014 10:34:17 上午 org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure INFO: HHH000046: Connection properties: {user=root, password=****} 五月 13, 2014 10:34:17 上午 org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure 这句 org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider configure​ 到这里就不在向下执行.在Debug模式就没有任何问题,创建SessionFactory和Crud都正常. 数据库驱动,hibernate4小版本号够尝试换成别的版本,都没能解决问题. 请大家指教!谢谢
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
C语言荣获2019年度最佳编程语言
关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang近日,TIOBE官方发布了2020年1月编程语言排行榜单。我在前面给过一篇文章《2019年11月C语言接近Ja...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
应届生/社招面试最爱问的几道Java基础问题
本文已经收录自笔者开源的 JavaGuide: https://github.com/Snailclimb (【Java学习 面试指南】 一份涵盖大部分Java程序员所需要掌握的核心知识)如果觉得不错的还,不妨去点个Star,鼓励一下! 一 为什么 Java 中只有值传递? 首先回顾一下在程序设计语言中有关将参数传递给方法(或函数)的一些专业术语。按值调用(call by value)表...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
Idea 中最常用的10款插件(提高开发效率),一定要学会使用!
学习使用一些插件,可以提高开发效率。对于我们开发人员很有帮助。这篇博客介绍了开发中使用的插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
最全最强!世界大学计算机专业排名总结!
我正在参与CSDN200进20,希望得到您的支持,扫码续投票5次。感谢您! (为表示感谢,您投票后私信我,我把我总结的人工智能手推笔记和思维导图发送给您,感谢!) 目录 泰晤士高等教育世界大学排名 QS 世界大学排名 US News 世界大学排名 世界大学学术排名(Academic Ranking of World Universities) 泰晤士高等教育世界大学排名 中国共...
一份王者荣耀的英雄数据报告
咪哥杂谈本篇阅读时间约为 6 分钟。1前言前一阵写了关于王者的一些系列文章,从数据的获取到数据清洗,数据落地,都是为了本篇的铺垫。今天来实现一下,看看不同维度得到的结论。2环境准备本次实...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
立即提问