-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can not insert data to database table.
PostPosted: Wed Dec 07, 2005 10:23 pm 
Newbie

Joined: Sat Jul 23, 2005 1:57 am
Posts: 2
After insertion,there is no data exists in the USERS table.
Any help is appreciated.

Hibernate version:
3.1alpha1
Mapping documents:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="dms.modual.User" table="USERS">
<id name="id" type="java.lang.Long" column="ID">
<generator class="identity"/>
</id>
<property name="rootFolderId" type="java.lang.Integer" column="ROOT_FOLDER_ID"/>
<property name="rootDeptId" type="java.lang.Integer" column="ROOT_DEPT_ID"/>
<property name="userName" type="java.lang.String" column="USER_NAME" not-null="true" length="100"/>
<property name="password" type="java.lang.String" column="PASSWORD" length="100"/>
<property name="userRank" type="java.lang.Integer" column="USER_RANK"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
UserForm userForm=(UserForm)form;
User user=new User();
user.setUserName(userForm.getUserName());
user.setPassword(userForm.getPassword1());
user.setRootDeptId(new Integer(userForm.getRootDeptId()));
user.setRootFolderId(new Integer(userForm.getRootFolderId()));
user.setUserRank(new Integer(userForm.getUserRank()));
Session dbSession=appSessionFactory.currentSession();
Transaction tx=null;
try{
tx=dbSession.beginTransaction();
dbSession.save(user);
}
catch(Exception ex){
if(tx != null) {
tx.rollback();
}
ex.printStackTrace();
}
finally{
appSessionFactory.closeSession();
}

Full stack trace of any exception that occurs:
No exception,the following logs is useful.
2005-12-08 10:08:46,562 INFO [org.hibernate.util.NamingHelper] - <JNDI InitialContext properties:{}>
2005-12-08 10:08:46,562 INFO [org.hibernate.connection.DatasourceConnectionProvider] - <Using datasource: java:/comp/env/jdbc/DMSJNDI>
2005-12-08 10:08:46,906 INFO [org.hibernate.cfg.SettingsFactory] - <RDBMS: MySQL, version: 5.0.16-nt>
2005-12-08 10:08:46,906 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )>
2005-12-08 10:08:46,937 INFO [org.hibernate.dialect.Dialect] - <Using dialect: org.hibernate.dialect.MySQLDialect>
2005-12-08 10:08:46,953 INFO [org.hibernate.transaction.TransactionFactoryFactory] - <Using default transaction strategy (direct JDBC transactions)>
2005-12-08 10:08:46,953 INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - <No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Automatic flush during beforeCompletion(): disabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Automatic session close at end of transaction: disabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC batch size: 15>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC batch updates for versioned data: disabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Scrollable result sets: enabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <JDBC3 getGeneratedKeys(): enabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Connection release mode: null>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Maximum outer join fetch depth: 2>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Default batch fetch size: 1>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Generate SQL with comments: disabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Order SQL updates by primary key: disabled>
2005-12-08 10:08:46,953 INFO [org.hibernate.cfg.SettingsFactory] - <Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory>
2005-12-08 10:08:46,968 INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - <Using ASTQueryTranslatorFactory>
2005-12-08 10:08:46,968 INFO [org.hibernate.cfg.SettingsFactory] - <Query language substitutions: {}>
2005-12-08 10:08:46,968 INFO [org.hibernate.cfg.SettingsFactory] - <Second-level cache: enabled>
2005-12-08 10:08:46,968 INFO [org.hibernate.cfg.SettingsFactory] - <Query cache: disabled>
2005-12-08 10:08:46,968 INFO [org.hibernate.cfg.SettingsFactory] - <Cache provider: org.hibernate.cache.EhCacheProvider>
2005-12-08 10:08:46,984 INFO [org.hibernate.cfg.SettingsFactory] - <Optimize cache for minimal puts: disabled>
2005-12-08 10:08:46,984 INFO [org.hibernate.cfg.SettingsFactory] - <Structured second-level cache entries: disabled>
2005-12-08 10:08:46,984 INFO [org.hibernate.cfg.SettingsFactory] - <Echoing all SQL to stdout>
2005-12-08 10:08:46,984 INFO [org.hibernate.cfg.SettingsFactory] - <Statistics: disabled>
2005-12-08 10:08:46,984 INFO [org.hibernate.cfg.SettingsFactory] - <Deleted entity synthetic identifier rollback: disabled>
2005-12-08 10:08:46,984 INFO [org.hibernate.cfg.SettingsFactory] - <Default entity-mode: pojo>
2005-12-08 10:08:47,140 INFO [org.hibernate.impl.SessionFactoryImpl] - <building session factory>
2005-12-08 10:08:47,140 WARN [net.sf.ehcache.config.Configurator] - <No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/F:/techPrac/DMS/WebApp/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml>
2005-12-08 10:08:47,546 INFO [org.hibernate.impl.SessionFactoryObjectFactory] - <Not binding factory to JNDI, no JNDI name configured>
2005-12-08 10:08:47,546 INFO [org.hibernate.impl.SessionFactoryImpl] - <Checking 0 named queries>

Name and version of the database you are using:
mysql version:5.0.16-nt
The generated SQL (show_sql=true):
insert into USERS (ROOT_FOLDER_ID,ROOT_DEPT_ID,USER_NAME,PASSWORD,USER_RANK) VALUES(?,?,?,?,?)
Debug level Hibernate log excerpt:
INFO


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 12:09 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
tx.commit() ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.