-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Commit is not Working
PostPosted: Mon Sep 12, 2005 3:22 am 
Newbie

Joined: Tue Aug 09, 2005 1:42 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0..
Database is finding to fall on an infinite loop.....No data is not saving......but method return the return statement "DATA SAVE SUCCESSFULLY"
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="Tb_User" table="tb_user">

<id name="user_name" unsaved-value="null">
<column name="user_name" sql-type="varchar(20)" not-null="true"/>
<generator class="assigned">
</generator>

</id>

<property name="pwd"><column name="pwd" sql-type="varchar(50)" /></property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
<code>public String greet(String str){

try
{


new Configuration().configure().buildSessionFactory();
Context ctx = new InitialContext();
SessionFactory sessionFactory = (SessionFactory) ctx.lookup("java:/comp/Hello");

Session session = sessionFactory.openSession();
Tb_User test=new Tb_User("mn","bh");

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();


return "DATA SAVED SUCESSFULLY";

}catch(Exception e)
{
System.out.println(e);
return e.toString();

}

}
</code>
Full stack trace of any exception that occurs:
12:28:23,265 INFO [STDOUT] setSessionContext()
12:28:23,265 INFO [STDOUT] ejbcreate()
12:28:23,265 INFO [Configuration] configuring from resource: /hibernate.cfg.xml

12:28:23,265 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
12:28:23,281 INFO [Configuration] Mapping resource: Tb_User.hbm.xml
12:28:23,281 INFO [HbmBinder] Mapping class: Tb_User -> tb_user
12:28:23,281 INFO [Configuration] Configured SessionFactory: java:/comp/Hello
12:28:23,281 INFO [Configuration] processing extends queue
12:28:23,281 INFO [Configuration] processing collection mappings
12:28:23,281 INFO [Configuration] processing association property references
12:28:23,281 INFO [Configuration] processing foreign key constraints
12:28:23,296 INFO [ConnectionProviderFactory] Initializing connection provider:
org.hibernate.connection.DriverManagerConnectionProvider
12:28:23,296 INFO [DriverManagerConnectionProvider] Using Hibernate built-in co
nnection pool (not for production use!)
12:28:23,296 INFO [DriverManagerConnectionProvider] Hibernate connection pool s
ize: 10
12:28:23,296 INFO [DriverManagerConnectionProvider] autocommit mode: false
12:28:23,296 INFO [DriverManagerConnectionProvider] using driver: com.microsoft
.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://192.168.16.5:
1433
12:28:23,296 INFO [DriverManagerConnectionProvider] connection properties: {use
r=sa, password=sa}
12:28:23,375 INFO [SettingsFactory] RDBMS: Microsoft SQL Server, version: Micro
soft SQL Server 2000 - 8.00.194 (Intel X86)
Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Personal Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

12:28:23,375 INFO [SettingsFactory] JDBC driver: SQLServer, version: 2.2.0040
12:28:23,375 INFO [Dialect] Using dialect: org.hibernate.dialect.SQLServerDiale
ct
12:28:23,375 INFO [TransactionFactoryFactory] Transaction strategy: org.hiberna
te.transaction.JTATransactionFactory
12:28:23,375 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.pr
ovider.url=jnp://localhost:1099, java.naming.factory.initial=org.jnp.interfaces.
NamingContextFactory}
12:28:23,375 INFO [TransactionManagerLookupFactory] instantiating TransactionMa
nagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
12:28:23,375 INFO [TransactionManagerLookupFactory] instantiated TransactionMan
agerLookup
12:28:23,375 INFO [TransactionManagerLookupFactory] instantiating TransactionMa
nagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
12:28:23,390 INFO [TransactionManagerLookupFactory] instantiated TransactionMan
agerLookup
12:28:23,390 INFO [SettingsFactory] Automatic flush during beforeCompletion():
disabled
12:28:23,390 INFO [SettingsFactory] Automatic session close at end of transacti
on: disabled
12:28:23,390 INFO [SettingsFactory] Scrollable result sets: enabled
12:28:23,390 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
12:28:23,390 INFO [SettingsFactory] Connection release mode: null
12:28:23,390 INFO [SettingsFactory] Default batch fetch size: 1
12:28:23,390 INFO [SettingsFactory] Generate SQL with comments: disabled
12:28:23,390 INFO [SettingsFactory] Order SQL updates by primary key: disabled
12:28:23,390 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.AST
QueryTranslatorFactory
12:28:23,390 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
12:28:23,390 INFO [SettingsFactory] Query language substitutions: {}
12:28:23,390 INFO [SettingsFactory] Second-level cache: enabled
12:28:23,390 INFO [SettingsFactory] Query cache: disabled
12:28:23,390 INFO [SettingsFactory] Cache provider: org.hibernate.cache.Hashtab
leCacheProvider
12:28:23,390 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
12:28:23,390 INFO [SettingsFactory] Structured second-level cache entries: disa
bled
12:28:23,390 INFO [SettingsFactory] Echoing all SQL to stdout
12:28:23,390 INFO [SettingsFactory] Statistics: disabled
12:28:23,390 INFO [SettingsFactory] Deleted entity synthetic identifier rollbac
k: disabled
12:28:23,390 INFO [SettingsFactory] Default entity-mode: pojo
12:28:23,390 INFO [SessionFactoryImpl] building session factory
12:28:23,390 INFO [SessionFactoryObjectFactory] Factory name: java:/comp/Hello
12:28:23,390 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.pr
ovider.url=jnp://localhost:1099, java.naming.factory.initial=org.jnp.interfaces.
NamingContextFactory}
12:28:23,390 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: jav
a:/comp/Hello
12:28:23,390 WARN [SessionFactoryObjectFactory] InitialContext did not implemen
t EventContext
12:28:23,406 INFO [Dialect] Using dialect: org.hibernate.dialect.SQLServerDiale
ct
12:28:23,406 INFO [Configuration] processing extends queue
12:28:23,406 INFO [Configuration] processing collection mappings
12:28:23,406 INFO [Configuration] processing association property references
12:28:23,406 INFO [Configuration] processing foreign key constraints
12:28:23,406 INFO [Configuration] processing extends queue
12:28:23,406 INFO [Configuration] processing collection mappings
12:28:23,406 INFO [Configuration] processing association property references
12:28:23,406 INFO [Configuration] processing foreign key constraints
12:28:23,406 INFO [SchemaExport] Running hbm2ddl schema export
12:28:23,406 INFO [SchemaExport] exporting generated schema to database
12:28:23,406 INFO [ConnectionProviderFactory] Initializing connection provider:
org.hibernate.connection.DriverManagerConnectionProvider
12:28:23,406 INFO [DriverManagerConnectionProvider] Using Hibernate built-in co
nnection pool (not for production use!)
12:28:23,406 INFO [DriverManagerConnectionProvider] Hibernate connection pool s
ize: 10
12:28:23,406 INFO [DriverManagerConnectionProvider] autocommit mode: false
12:28:23,406 INFO [DriverManagerConnectionProvider] using driver: com.microsoft
.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://192.168.16.5:
1433
12:28:23,406 INFO [DriverManagerConnectionProvider] connection properties: {use
r=sa, password=sa}
12:28:23,578 INFO [SchemaExport] schema export complete
12:28:23,578 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
12:28:23,578 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Database changed to master
12:28:23,578 WARN [JDBCExceptionReporter] SQL Warning: 5701, SQLState: 01000
12:28:23,578 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed database context to 'master'.
12:28:23,578 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
12:28:23,578 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Language changed to us_english
12:28:23,578 WARN [JDBCExceptionReporter] SQL Warning: 5703, SQLState: 01000
12:28:23,578 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed language setting to us_english.
12:28:23,578 INFO [DriverManagerConnectionProvider] cleaning up connection pool
: jdbc:microsoft:sqlserver://192.168.16.5:1433
12:28:23,578 INFO [Dialect] Using dialect: org.hibernate.dialect.SQLServerDiale
ct
12:28:23,578 INFO [Configuration] processing extends queue
12:28:23,578 INFO [Configuration] processing collection mappings
12:28:23,578 INFO [Configuration] processing association property references
12:28:23,578 INFO [Configuration] processing foreign key constraints
12:28:23,578 INFO [Configuration] processing extends queue
12:28:23,578 INFO [Configuration] processing collection mappings
12:28:23,578 INFO [Configuration] processing association property references
12:28:23,578 INFO [Configuration] processing foreign key constraints
12:28:23,578 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.pr
ovider.url=jnp://localhost:1099, java.naming.factory.initial=org.jnp.interfaces.
NamingContextFactory}
12:28:23,578 INFO [SessionFactoryImpl] Checking 0 named queries
12:28:23,593 INFO [STDOUT] After session.save
12:28:23,593 INFO [STDOUT] Hibernate: insert into tb_user (pwd, user_name) valu
es (?, ?)
12:28:23,593 INFO [STDOUT] After transaction commit
12:28:23,593 INFO [STDOUT] After flush
12:28:23,593 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
12:28:23,593 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Database changed to master
12:28:23,593 WARN [JDBCExceptionReporter] SQL Warning: 5701, SQLState: 01000
12:28:23,593 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed database context to 'master'.
12:28:23,593 WARN [JDBCExceptionReporter] SQL Warning: 0, SQLState:
12:28:23,593 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC]Language changed to us_english
12:28:23,593 WARN [JDBCExceptionReporter] SQL Warning: 5703, SQLState: 01000
12:28:23,593 WARN [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for
JDBC][SQLServer]Changed language setting to us_english.
12:28:25,203 INFO [DriverManagerConnectionProvider] cleaning up connection pool
: jdbc:microsoft:sqlserver://192.168.16.5:1433

Name and version of the database you are using:
MS SQL Server
The generated SQL (show_sql=true):
Hibernate: insert into tb_user (pwd, user_name) valu
es (?, ?)

Debug level Hibernate log excerpt:

[code][/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.