Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.5
Mapping documents:
<hibernate-configuration>
<session-factory>
<!-- <property name="hibernate.connection.datasource">java:MySqlDS</property> -->
<property name="hibernate.session_factory_name">java:Mydatabase</property>
<property name="hibernate.jndi.url"></property>
<property name="hibernate.jndi.class"></property>
<property name="hibernate.connection.username"></property>
<property name="hibernate.connection.password"></property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- Show and print nice SQL on stdout. -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- List of XML Mapping files -->
<mapping resource="contact.hbm.xml"/>
<!-- <mapping resource="address.hbm.xml"/> -->
</session-factory>
</hibernate-configuration>
Code between sessionFactory.openSession() and session.close():
Session session = null;
try{
System.out.println("Before Session Factory Configuration. !!!");
SessionFactory sf = new Configuration().configure().buildSessionFactory();
jndiContext = new InitialContext();
sf = (SessionFactory)jndiContext.lookup("java:MySqlDS");
session = sf.openSession();
System.out.println("After Session Factory Configuration. !!!");
}catch(Exception e){
e.printStackTrace();
}finally{
session.flush();
session.close();
}
Full stack trace of any exception that occurs:
Name and version of the database you are using: MySQL 5.0.45
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Hi All,
1) Please help me in configuring JNDI bound SessionFactory in Hibernate. I am using MySQL database and JBoss 4.2.2 app. server. Please help me I am not getting help/clue from anywhere. I have searched the net also. Anyhelp will be highly appreciated. Thanks in advance. I have tried writing a simple program but it dosen't work.
2) Is configuring a datasource and configuring JNDI bound SessionFactory one and the same thing. If No then how to configure a datasource using the same above configuration.
Please Help !!!
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html