I am using derby database and here is my main class code
package com.hibernate.test;
import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.tool.hbm2ddl.SchemaExport; import com.hibernate.example.Employee;
public class TestEmployee {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try{ AnnotationConfiguration config = new AnnotationConfiguration(); config.addAnnotatedClass(Employee.class); config.configure(); new SchemaExport(config).create(true, true); SessionFactory factory = config.buildSessionFactory(); Session session = factory.getCurrentSession(); session.beginTransaction(); Employee emp = new Employee(); emp.setEmpId(1); emp.setEmpName("Vamshi krishnam raju"); session.save(emp); session.getTransaction().commit(); }catch (Exception e) { // TODO: handle exception e.printStackTrace(); } }
}
console Output :
18:21:10,941 INFO Version:15 - Hibernate Annotations 3.4.0.GA 18:21:10,964 INFO Environment:560 - Hibernate 3.3.2.GA 18:21:10,968 INFO Environment:593 - hibernate.properties not found 18:21:10,973 INFO Environment:771 - Bytecode provider name : javassist 18:21:10,979 INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling 18:21:11,089 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA 18:21:11,103 INFO Configuration:1474 - configuring from resource: /hibernate.cfg.xml 18:21:11,104 INFO Configuration:1451 - Configuration resource: /hibernate.cfg.xml 18:21:11,221 INFO Configuration:1589 - Configured SessionFactory: null 18:21:11,252 INFO Dialect:175 - Using dialect: org.hibernate.dialect.DerbyDialect 18:21:11,387 INFO AnnotationBinder:419 - Binding entity from annotated class: com.hibernate.example.Employee 18:21:11,449 INFO EntityBinder:422 - Bind entity com.hibernate.example.Employee on table Employee 18:21:11,596 INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring 18:21:11,686 INFO SchemaExport:226 - Running hbm2ddl schema export 18:21:11,687 DEBUG SchemaExport:242 - import file not found: /import.sql 18:21:11,688 INFO SchemaExport:251 - exporting generated schema to database 18:21:11,692 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!) 18:21:11,692 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 1 18:21:11,693 INFO DriverManagerConnectionProvider:68 - autocommit mode: false 18:21:11,709 INFO DriverManagerConnectionProvider:103 - using driver: org.apache.derby.jdbc.ClientDriver at URL: jdbc:derby://localhost:1527/Hibernate;create=true 18:21:11,709 INFO DriverManagerConnectionProvider:109 - connection properties: {user=user, password=****} drop table TestSchema.Employee 18:21:11,997 DEBUG SchemaExport:377 - drop table TestSchema.Employee create table TestSchema.Employee (empId integer not null, empName varchar(255), primary key (empId)) 18:21:12,158 DEBUG SchemaExport:377 - create table TestSchema.Employee (empId integer not null, empName varchar(255), primary key (empId)) 18:21:12,359 INFO SchemaExport:268 - schema export complete 18:21:12,363 INFO DriverManagerConnectionProvider:170 - cleaning up connection pool: jdbc:derby://localhost:1527/Hibernate;create=true 18:21:12,372 INFO HibernateSearchEventListenerRegister:53 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 18:21:12,381 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!) 18:21:12,382 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 1 18:21:12,383 INFO DriverManagerConnectionProvider:68 - autocommit mode: false 18:21:12,385 INFO DriverManagerConnectionProvider:103 - using driver: org.apache.derby.jdbc.ClientDriver at URL: jdbc:derby://localhost:1527/Hibernate;create=true 18:21:12,385 INFO DriverManagerConnectionProvider:109 - connection properties: {user=user, password=****} 18:21:12,397 INFO SettingsFactory:114 - RDBMS: Apache Derby, version: 10.7.1.1 - (1040133) 18:21:12,398 INFO SettingsFactory:115 - JDBC driver: Apache Derby Network Client JDBC Driver, version: 10.7.1.1 - (1040133) 18:21:12,419 INFO Dialect:175 - Using dialect: org.hibernate.dialect.DerbyDialect 18:21:12,476 INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions) 18:21:12,478 INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 18:21:12,479 INFO SettingsFactory:161 - Automatic flush during beforeCompletion(): disabled 18:21:12,479 INFO SettingsFactory:165 - Automatic session close at end of transaction: disabled 18:21:12,481 INFO SettingsFactory:180 - Scrollable result sets: enabled 18:21:12,482 INFO SettingsFactory:188 - JDBC3 getGeneratedKeys(): disabled 18:21:12,482 INFO SettingsFactory:196 - Connection release mode: auto 18:21:12,483 INFO SettingsFactory:214 - Default schema: TestSchema 18:21:12,484 INFO SettingsFactory:223 - Default batch fetch size: 1 18:21:12,484 INFO SettingsFactory:227 - Generate SQL with comments: disabled 18:21:12,484 INFO SettingsFactory:231 - Order SQL updates by primary key: disabled 18:21:12,484 INFO SettingsFactory:235 - Order SQL inserts for batching: disabled 18:21:12,485 INFO SettingsFactory:397 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 18:21:12,487 INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory 18:21:12,488 INFO SettingsFactory:243 - Query language substitutions: {} 18:21:12,488 INFO SettingsFactory:248 - JPA-QL strict compliance: disabled 18:21:12,488 INFO SettingsFactory:253 - Second-level cache: enabled 18:21:12,489 INFO SettingsFactory:257 - Query cache: disabled 18:21:12,495 INFO SettingsFactory:382 - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge 18:21:12,496 INFO RegionFactoryCacheProviderBridge:61 - Cache provider: org.hibernate.cache.internal.NoCacheProvider org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge] at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:389) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:262) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) at com.hibernate.test.TestEmployee.main(TestEmployee.java:21) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.hibernate.cfg.SettingsFactory.createRegionFactory(SettingsFactory.java:384) ... 6 more Caused by: org.hibernate.cache.CacheException: could not instantiate CacheProvider [org.hibernate.cache.internal.NoCacheProvider] at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:66) ... 11 more Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.internal.NoCacheProvider at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192) at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.<init>(RegionFactoryCacheProviderBridge.java:63) ... 11 more
Please give me u r suggestions ...
|