Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: hibernate3.0
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="newtry_test" table="newtry_test">
<id name="uname" unsaved-value="null" >
<column name="uname" sql-type="varchar(20)" not-null="true"/>
<generator class="assigned">
</generator>
</id>
<!--property name="userName"/-->
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
try
{
//str=str+"Hello From StateLess Session Bean";
System.out.println(str);
Configuration cfg = new Configuration();
/*.addClass(newtry_test.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect")
.setProperty("hibernate.connection.driver_class", "com.microsoft.jdbc.sqlserver.SQLServerDriver")
.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://192.168.16.5:1433")
.setProperty("hibernate.connection.username", "sa")
.setProperty("hibernate.connection.password", "sa")
.setProperty("hibernate.hbm2ddl.auto", "update")
.setProperty("hibernate.show_sql", "true");*/
cfg.configure(new File(System.getProperties().getProperty("sun.boot.library.path")+"\\hibernate.cfg.xml")).buildSessionFactory();
//.buildSessionFactory();
//cfg.configure(new File("D:\\newtry\\jar\\hibernate.cfg.xml"));
System.out.println("hjhk");
Context ctx = new InitialContext();
SessionFactory sessionFactory = (SessionFactory) ctx.lookup("java:/MSSQLDS");
Session session = sessionFactory.openSession();
//System.out.println("null sessionfactory");
//SessionFactory sessionFactory = cfg.buildSessionFactory();
System.out.println("bnmbnmbm");
//Configuration config = new Configuration().addResource("d:\\newtry\\jar\\newtry_test.hbm.xml")
/*Configuration config = new Configuration().addClass(d:\\newtry\\jar\\newtry_test.class)
.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLServerDialect")
.setProperty("hibernate.connection.driver_class", " com.microsoft.jdbc.sqlserver.SQLServerDriver")
.setProperty("hibernate.connection.url", "jdbc:microsoft:sqlserver://localhost:1433/msdb");
SessionFactory session = config.buildSessionFactory();*/
newtry_test test=new newtry_test(str);
//Context ctx=new InitialContext();
//Session session;
///Session session = (sessionFactory)ctx.lookup("java:/MSSQLDS");
//Session session = cfg.openSession();
Transaction tx = session.beginTransaction();
session.save(test);
System.out.println("After session.save");
tx.commit();
System.out.println("After transaction commit");
session.flush();
System.out.println("After flush");
session.close();
//str=str+"Hello From StateLess Session Bean";
return "DATA SAVED SUCESSFULLY";
}catch(Exception e)
{
System.out.println(e);
return e.toString();
//return "From StatelesBean Interface";
}
}
}
Full stack trace of any exception that occurs:
No exception is occurd.Table generation done by hibernate.But,no data is entering in table.Query is not performed.It 's find like an infinite loop.
Can u give code or any link from I can understand how can I solve this problem.
When I am not using datasource it's work fine.
Name and version of the database you are using:
MS SQL Server 2000
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
log 4j