Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version: 3.0[/b]
[b]Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<!-- Generated file - Do not edit! -->
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">false</property>
<property name="connection.username">user</property>
<property name="connection.password">username</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://ipaddress:port/dbname</property>
<!-- mapping files -->
<mapping resource="com/gloptv/smsc/Customer.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Parameter.hbm.xml"/>
<mapping resource="com/gloptv/smsc/User.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Application.hbm.xml"/>
<mapping resource="com/gloptv/smsc/PhoneNumber.hbm.xml"/>
<mapping resource="com/gloptv/smsc/SmsOut.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Operator.hbm.xml"/>
<mapping resource="com/gloptv/smsc/SmsIn.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Synchro.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Keyword.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Status.hbm.xml"/>
</session-factory>
</hibernate-configuration>
[/b]
[b]Code between sessionFactory.openSession() and session.close():
try
{
session = HibernateUtil.currentSession();
tx = session.beginTransaction();
// do insert into database
tx.commit();
}
catch(Exception e)
{
if (tx != null)
tx.rollback();
}
finally
{
session.close();
HibernateUtil.closeSession();
}
[/b]
[b]Full stack trace of any exception that occurs:[/b]
[b]Name and version of the database you are using:Postgresql 8.0[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:
May 2, 2005 11:05:35 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0
May 2, 2005 11:05:35 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
May 2, 2005 11:05:35 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
May 2, 2005 11:05:35 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
May 2, 2005 11:05:36 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
May 2, 2005 11:05:36 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Customer.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Customer -> customer
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Parameter.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Parameter -> parameter
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/User.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.User -> smsc_user
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Application.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Application -> application
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/PhoneNumber.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.PhoneNumber -> phone_number
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/SmsOut.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.SmsOut -> sms_out
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Operator.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Operator -> operator
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/SmsIn.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.SmsIn -> sms_in
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Synchro.hbm.xml
May 2, 2005 11:05:37 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Synchro -> synchro
May 2, 2005 11:05:37 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Keyword.hbm.xml
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Keyword -> keyword
May 2, 2005 11:05:38 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Status.hbm.xml
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Status -> status
May 2, 2005 11:05:38 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
May 2, 2005 11:05:38 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
May 2, 2005 11:05:38 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Customer.phoneNumbers -> phone_number
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.User.customers -> customer
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Application.keywords -> keyword
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Application.parameters -> parameter
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.PhoneNumber.keywords -> keyword
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Operator.synchros -> synchro
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Operator.smsIns -> sms_in
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.SmsIn.smsOuts -> sms_out
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Keyword.smsIns -> sms_in
May 2, 2005 11:05:38 AM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Status.smsOuts -> sms_out
May 2, 2005 11:05:38 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
May 2, 2005 11:05:38 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
May 2, 2005 11:05:38 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.PostgreSQLDialect
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
May 2, 2005 11:05:38 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
May 2, 2005 11:05:38 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 2, 2005 11:05:38 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
May 2, 2005 11:05:38 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
May 2, 2005 11:05:38 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.postgresql.Driver at URL: jdbc:postgresql://192.168.2.1:5432/smsc
May 2, 2005 11:05:38 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=glop, password=****}
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
May 2, 2005 11:05:38 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
May 2, 2005 11:05:38 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: enabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
May 2, 2005 11:05:38 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
May 2, 2005 11:05:38 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
May 2, 2005 11:05:38 AM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/hibernate-3.0/lib/ehcach
e-1.1.jar!/ehcache-failsafe.xml
May 2, 2005 11:05:40 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
May 2, 2005 11:05:40 AM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
[/b]
Hi, my problem is that when I call the function that will execute the above code in a console, everything works fine (Log from hibernate are shown above), but when I call the same function
from a jsp page in Tomcat, it seems that the transaction does not end. When I look in the Posgresql log, I found that the transaction is idle, as if it has not been commited. But the insert has been done correctly.
Can anyone please tell me what is causing this? Should I specify a transaction manager when calling that same function from Tomcat, since I found the following in the log:
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
thanks in advance