how to fix org.hibernate.HibernateException
i am using eclipse and oracle 10g

thanking you

Recommended Answers

All 3 Replies

This isn't enough information to be helpful. Please post your compiler error output here. Thanks. Also, post the relevant source code.


package com.hibernate.oracle;

import javax.persistence.Entity;
import javax.persistence.Id;

public class Employee {
private int empId;
private String empName;

public int getEmpId() {
    return empId;
public void setEmpId(int empId) {
    this.empId = empId;
public String getEmpName() {
    return empName;
public void setEmpName(String empName) {
    this.empName = empName;



package com.hibernate.oracle;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
//import org.hibernate.tool.hbm2ddl.SchemaExport;

public class TestEmployee {

     * @param args
    public static void main(String[] args) {
        AnnotationConfiguration config = new AnnotationConfiguration();

        //new SchemaExport(config).create(true,true);

        SessionFactory factory = config.buildSessionFactory();
        Session session = factory.getCurrentSession();

        Employee g = new Employee();





14:11:13,753  INFO Version:15 - Hibernate Annotations 3.4.0.GA
14:11:13,800  INFO Environment:560 - Hibernate 3.3.2.GA
14:11:13,800  INFO Environment:593 - hibernate.properties not found
14:11:13,815  INFO Environment:771 - Bytecode provider name : javassist
14:11:13,815  INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling
14:11:14,065  INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
14:11:14,096  INFO Configuration:1474 - configuring from resource: hibernate.cfg.xml
14:11:14,096  INFO Configuration:1451 - Configuration resource: hibernate.cfg.xml
14:11:14,316  INFO Configuration:1589 - Configured SessionFactory: null
14:11:14,331  INFO HibernateSearchEventListenerRegister:53 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
14:11:14,472  INFO AnnotationBinder:419 - Binding entity from annotated class: com.hibernate.oracle.Employee
14:11:14,581  INFO EntityBinder:422 - Bind entity com.hibernate.oracle.Employee on table Employee
14:11:14,674  INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
14:11:14,815  INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
14:11:14,815  INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 2
14:11:14,815  INFO DriverManagerConnectionProvider:68 - autocommit mode: false
14:11:14,830  INFO DriverManagerConnectionProvider:103 - using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521
14:11:14,830  INFO DriverManagerConnectionProvider:109 - connection properties: {user=ganga, password=****}
14:11:15,969  WARN SettingsFactory:133 - Could not obtain connection to query metadata
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
    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.oracle.TestEmployee.main(TestEmployee.java:20)
14:11:16,034  INFO Dialect:175 - Using dialect: org.hibernate.dialect.OracleDialect
14:11:16,049  WARN Oracle9Dialect:60 - The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
14:11:16,049  WARN OracleDialect:49 - The OracleDialect dialect has been deprecated; use Oracle8iDialect instead
14:11:16,065  INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
14:11:16,065  INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
14:11:16,065  INFO SettingsFactory:161 - Automatic flush during beforeCompletion(): disabled
14:11:16,065  INFO SettingsFactory:165 - Automatic session close at end of transaction: disabled
14:11:16,065  INFO SettingsFactory:180 - Scrollable result sets: disabled
14:11:16,065  INFO SettingsFactory:188 - JDBC3 getGeneratedKeys(): disabled
14:11:16,065  INFO SettingsFactory:196 - Connection release mode: auto
14:11:16,065  INFO SettingsFactory:223 - Default batch fetch size: 1
14:11:16,065  INFO SettingsFactory:227 - Generate SQL with comments: disabled
14:11:16,065  INFO SettingsFactory:231 - Order SQL updates by primary key: disabled
14:11:16,065  INFO SettingsFactory:235 - Order SQL inserts for batching: disabled
14:11:16,065  INFO SettingsFactory:397 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:11:16,080  INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
14:11:16,080  INFO SettingsFactory:243 - Query language substitutions: {}
14:11:16,080  INFO SettingsFactory:248 - JPA-QL strict compliance: disabled
14:11:16,080  INFO SettingsFactory:253 - Second-level cache: enabled
14:11:16,080  INFO SettingsFactory:257 - Query cache: disabled
14:11:16,096  INFO SettingsFactory:382 - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
14:11:16,096  INFO RegionFactoryCacheProviderBridge:61 - Cache provider: org.hibernate.cache.NoCacheProvider
14:11:16,096  INFO SettingsFactory:267 - Optimize cache for minimal puts: disabled
14:11:16,096  INFO SettingsFactory:276 - Structured second-level cache entries: disabled
14:11:16,096  INFO SettingsFactory:296 - Echoing all SQL to stdout
14:11:16,096  INFO SettingsFactory:305 - Statistics: disabled
14:11:16,096  INFO SettingsFactory:309 - Deleted entity synthetic identifier rollback: disabled
14:11:16,096  INFO SettingsFactory:324 - Default entity-mode: pojo
14:11:16,096  INFO SettingsFactory:328 - Named query checking : enabled
14:11:16,236  INFO SessionFactoryImpl:193 - building session factory
14:11:16,673  INFO SessionFactoryObjectFactory:105 - Not binding factory to JNDI, no JNDI name configured
Exception in thread "main" org.hibernate.HibernateException: save is not valid without active transaction
    at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:338)
    at $Proxy5.save(Unknown Source)
    at com.hibernate.oracle.TestEmployee.main(TestEmployee.java:27)

This the error i am getting kindly help me to fix the problem

iam using oracle 10g and eclipse ide

thanks in advance

have a nice time

The first exception, java.sql.SQLException, is the one you need to resolve first. It is telling you that you have not connected successfully to the database. Anything after that won't work, hence the subsequent exceptions. Solve that one first. Maybe the database is inaccessible from your computer, or your database user/password is incorrect, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.