小弟第一次用hibernate连接oracle数据库遇到困难,求助大神
报错信息:587 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final
699 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.6.0.Final
714 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
758 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
784 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
1070 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate.cfg.xml
1070 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml
1604 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : com/yubiao/examples/Guestbook.hbm.xml
1935 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
2177 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: com.yubiao.examples.Guestbook -> guestbook
2283 [main] INFO org.hibernate.cfg.Configuration - Hibernate Validator not found: ignoring
2304 [main] INFO org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
2325 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
2325 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
2326 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
2460 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:MYORA1
2460 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=scott, password=****}
3550 [main] INFO org.hibernate.cfg.SettingsFactory - Database ->
name : Oracle
version : Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
major : 10
minor : 2
3550 [main] INFO org.hibernate.cfg.SettingsFactory - Driver ->
name : Oracle JDBC driver
version : 10.2.0.1.0XE
major : 10
minor : 2
3644 [main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.OracleDialect
3674 [main] WARN org.hibernate.dialect.Oracle9Dialect - The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
3683 [main] WARN org.hibernate.dialect.OracleDialect - The OracleDialect dialect has been deprecated; use Oracle8iDialect instead
3711 [main] INFO org.hibernate.engine.jdbc.JdbcSupportLoader - Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
3715 [main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
3720 [main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
3720 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
3721 [main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
3721 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
3721 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
3723 [main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
3724 [main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
3724 [main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
3725 [main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
3725 [main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
3725 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
3725 [main] INFO org.hibernate.cfg.SettingsFactory - Order SQL inserts for batching: disabled
3726 [main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
3748 [main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
3748 [main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
3748 [main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
3748 [main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
3748 [main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
3748 [main] INFO org.hibernate.cfg.SettingsFactory - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
3759 [main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
3759 [main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
3807 [main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
3807 [main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
3807 [main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
3807 [main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
3808 [main] INFO org.hibernate.cfg.SettingsFactory - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
4009 [main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
Exception in thread "main" org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:108)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:133)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:80)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:322)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:473)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:284)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
at com.yubiao.examples.HibernateTest.main(HibernateTest.java:25)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:105)
... 9 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for createdtime in class com.yubiao.examples.Guestbook
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:326)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:320)
at org.hibernate.mapping.Property.getGetter(Property.java:304)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:297)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:155)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:77)
... 14 more
hibernate配置文件:
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:MYORA1</property>
<property name="connection.username">scott</property>
<property name="connection.password">yyhshm520</property>
<property name="connection.pool_size">20</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">false</property>
<property name="format_sql">false</property>
<mapping resource="com/yubiao/examples/Guestbook.hbm.xml"/>
测试类:
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class HibernateTest {
public static void main(String[] args) {
Guestbook gb =new Guestbook();
gb.setName("于彪");
gb.setEmail("yyhshm520@163.com");
gb.setPhone("13564238317");
gb.setTitle("我写的第一个Hibernate程序");
gb.setContent("我感觉很爽!");
gb.setCreatedTime(new Date());
Configuration config =new Configuration();
config.configure();
SessionFactory sessionFactory =config.buildSessionFactory();
Session session= sessionFactory.getCurrentSession();
Transaction tx=session.beginTransaction();
session.save(gb);
tx.commit();
}
} --------------------编程问答-------------------- 帮帮忙大神们,自己顶一下,别沉 --------------------编程问答-------------------- 1935 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
你看看你读取hibernate的配置文件哪有问题 --------------------编程问答-------------------- Could not find a getter for createdtime in class com.yubiao.examples.Guestbook
com.yubiao.examples.Guestbook类的createdtime少了get方法
补充:Java , Java相关