Results 1 to 4 of 4
  1. #1
    rithish is offline Member
    Join Date
    Apr 2011
    Posts
    39
    Rep Power
    0

    Default Oracle 10g with hibernate

    Hello iam trying to use hibernate with oracle10g for the first time i get some problems

    Here is my entity class
    Java Code:
    package com.oracleconnect;
    
    import javax.persistence.Entity;
    public class OracleEntity {
    	
    	private int customerGroupID;
    	private String customerGroupName;
    	private String name;
    	private String city;
    	public OracleEntity(){
    		
    	}
    	public int getCustomerGroupID(){
    		return customerGroupID;
    	}
    	public void setCustomerGroupID(int customerGroupID){
    		this.customerGroupID = customerGroupID;
    	}
    	
    	public String getCustomerGroupName(){
    		return customerGroupName;
    	}
    	public void setCustomerGroupName(String customerGroupName){
    		this.customerGroupName = customerGroupName;
    	}
    	
    	public void setName(String name)
    	{
    		
    		
    		this.name=name;
    		
    		
    	}
    	public String getName()
    	{
    		
    		return name;
    		
    	}
    	public void setCity(String city)
    	{
    		this.city=city;
    		
    		
    	}
    	public String getCity()
    	{
    		
    		return city;
    		
    	}
    	
    	
    	
    	
    	
    
    }
    My hbm file

    Java Code:
    <?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 Jun 17, 2014 2:26:59 PM by Hibernate Tools 3.4.0.CR1 -->
    <hibernate-mapping>
        <class name="com.oracleconnect.OracleEntity" table="ORACLEENTITY">
           <id name="customerGroupID" type="int">
                <column name="CUSTOMERGROUPID" />
                <generator class="native" />
            </id>
            <property name="customerGroupName" type="java.lang.String">
                <column name="CUSTOMERGROUPNAME" />
            </property>
            <property name="name" type="java.lang.String">
                <column name="NAME" />
            </property>
            <property name="city" type="java.lang.String">
                <column name="CITY" />
            </property>
        </class>
    </hibernate-mapping>
    my cfg file

    Java Code:
    <?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="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password">google</property>
        <property name="connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
        
        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="hibernate.hbm2ddl.auto">create</property>
        <property name="hibernate.default_schema">sa</property>
        <mapping resource="com/oracleconnect/OracleEntity.hbm.xml"/>
        </session-factory>
        
    </hibernate-configuration>
    And my persisting class
    Java Code:
    package com.oracleconnect;
    
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    import org.hibernate.service.ServiceRegistry;
    import org.hibernate.service.ServiceRegistryBuilder;
    
    public class OracleEntityPersist {
    	
    	
    	public static void main(String[] args)
    	{
    		
    		Configuration cfg = new Configuration();
    		cfg.configure();
    		ServiceRegistry sr;
    		
    		sr = new ServiceRegistryBuilder().applySettings(cfg.getProperties()).build();
    		SessionFactory sfactory = cfg.buildSessionFactory(sr);
    		Session session = sfactory.openSession();
    		Transaction tr = null;
    		try{
    			tr = session.beginTransaction();
    			OracleEntity cg=new OracleEntity();
    			cg.setName("rithish abinav");
    			cg.setCustomerGroupName("rohinn");
    			
    			cg.setCity("chennai");
    			session.save(cg);
    			tr.commit();
    		}catch(Exception e){
    			e.printStackTrace();
    			if(tr != null)
    				tr.rollback();
    		}finally{
    			if(session != null)
    				session.close();
    		}
    		
    	}
    	
    	
    
    }
    The message and the error which i get is

    Java Code:
    Jun 23, 2014 9:39:46 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
    INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
    Jun 23, 2014 9:39:47 PM org.hibernate.Version logVersion
    INFO: HHH000412: Hibernate Core {4.3.5.Final}
    Jun 23, 2014 9:39:47 PM org.hibernate.cfg.Environment <clinit>
    INFO: HHH000206: hibernate.properties not found
    Jun 23, 2014 9:39:47 PM org.hibernate.cfg.Environment buildBytecodeProvider
    INFO: HHH000021: Bytecode provider name : javassist
    Jun 23, 2014 9:39:47 PM org.hibernate.cfg.Configuration configure
    INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
    Jun 23, 2014 9:39:47 PM org.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
    Jun 23, 2014 9:39:47 PM 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!
    Jun 23, 2014 9:39:47 PM org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: com/oracleconnect/OracleEntity.hbm.xml
    Jun 23, 2014 9:39:48 PM 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!
    Jun 23, 2014 9:39:48 PM org.hibernate.cfg.Configuration doConfigure
    INFO: HHH000041: Configured SessionFactory: null
    Jun 23, 2014 9:39:48 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
    Jun 23, 2014 9:39:48 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
    INFO: HHH000401: using driver [oracle.jdbc.driver.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:XE]
    Jun 23, 2014 9:39:48 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
    INFO: HHH000046: Connection properties: {user=sa, password=****}
    Jun 23, 2014 9:39:48 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
    INFO: HHH000006: Autocommit mode: false
    Jun 23, 2014 9:39:48 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
    Jun 23, 2014 9:39:51 PM org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
    WARN: HHH000341: Could not obtain connection metadata : Unsupported feature
    Jun 23, 2014 9:39:51 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
    INFO: HHH000422: Disabling contextual LOB creation as connection was null
    Exception in thread "main" java.lang.NullPointerException
    	at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244)
    	at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
    	at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
    	at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
    	at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
    	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    	at com.oracleconnect.OracleEntityPersist.main(OracleEntityPersist.java:21)

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: Oracle 10g with hibernate

    It's failing to build the session factory.

    "sourceforge"?
    How long ago was Hibernate part of sourceforge??
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,877
    Rep Power
    5

    Default Re: Oracle 10g with hibernate

    Hibernate itself has a perfectly valid quickstart guide with example programs:

    Hibernate Getting Started Guide
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    MaSan99 is offline Member
    Join Date
    Jun 2014
    Posts
    1
    Rep Power
    0

    Default Re: Oracle 10g with hibernate

    Hi,

    Even I faced the same problem. Add ojdbc6.jar instead of ojdbc14.jar.
    For more info refer java - Hibernate 4.3.5 is not working with Oracle10g Database - Stack Overflow

Similar Threads

  1. Hibernate Synchronizer property problem on Oracle 10g
    By zabeins in forum Advanced Java
    Replies: 0
    Last Post: 12-07-2011, 10:10 AM
  2. insert image to oracle using hibernate
    By Thennarasu in forum Advanced Java
    Replies: 12
    Last Post: 01-27-2009, 03:02 PM
  3. Replies: 4
    Last Post: 08-09-2007, 10:41 PM
  4. problem with hibernate and oracle 8i
    By javadev in forum JDBC
    Replies: 4
    Last Post: 08-09-2007, 02:21 PM
  5. can hibernate work with Oracle 10g
    By javadev in forum JDBC
    Replies: 4
    Last Post: 07-08-2007, 08:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •