Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Unable to implement persistence using Hibernate.
PostPosted: Thu May 31, 2012 12:09 am 
Newbie

Joined: Wed May 30, 2012 11:54 pm
Posts: 1
Hi All,

I am new to hibernate world.
I have written a small appllication in JSF+Hibernate.
I have all the required jar files and here is the code:

First the hibernate.cfg.xml file

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>

        <!-- Database connection settings -->
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="connection.url">localhost</property>
        <property name="connection.username">root</property>
        <property name="connection.password"></property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">update</property>
 
       <mapping resource="test.hbm.xml"/> 
       
         
    </session-factory>

</hibernate-configuration>



Now the test.hbm.xml


Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class name="com.myhibernate.classes.TestHibernate" table="HIBERNATE_TEST">
   <id name="id" type="int" column="ID" >
   <generator class="assigned"/>
  </id>

  <property name="name">
   <column name="NAME" />
  </property>
</class>
</hibernate-mapping>


is there anything wrong with these files.


Top
 Profile  
 
 Post subject: Re: Unable to implement persistence using Hibernate.
PostPosted: Thu May 31, 2012 2:43 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 988
Looks good but anyway in detail it really depends on which environment exactly you want to have (hibernate-version, database-version, etc.).
Do you get exceptions when starting you sample-app?
Can you report the exceptio with stacktraces?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.