Hi,
I'm having problems with hibernate using JDBC and MySQL. When using this configuration the data is *not* stored on the database, although the object's ID is updated. The log shows the INSERT being issued. This happens in a JUnit stand-alone test.
The *EXACT* same object (and code) is used inside the Application Server, using a Datasource and everything works like a charm. The only difference between both scenarios is the database config file (i am attaching both versions here).
Also if i manually store the object using jdbc (in JUnit OR inside the app server) everything works fine. (in this scenario no hibernate is used). I just dont know what else to try. I was thinking it *might* be a Transaction issue, but i think that all new connections with com.mysql.jdbc.Driver have AUTOCOMMIT enabled (even though, i use the same drivers for both App Server & JUnit versions).
These are my products versions.
Hibernate: 2.1.3
MySQL: 4.0.20a-nt
App Server: Weblogic 8.1
Driver: dont know..but it is always the same one.
I am also attaching Hibernate's log when it boots up.
Thank you very much for your help.
Regards,
Andres Bernasconi
ATTACHMENTS:
---------- JDBC cfg file -------------------
Code:
<?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">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/gastos
</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="show_sql">true</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- mapping files -->
<mapping resource="com/ntrc/gastos/bean/Periodo.hbm.xml"/>
</session-factory>
</hibernate-configuration>
---------- App Server cfg file -------------------
Code:
<?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">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="connection.datasource">jdbc/gastosDataSource</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- mapping files -->
<mapping resource="com/ntrc/gastos/bean/Periodo.hbm.xml"/>
</session-factory>
</hibernate-configuration>
---------- BOOT log (JUnit) -------------------
Code:
- Hibernate 2.1.3
- loaded properties from resource hibernate.properties: {hibernate.cache.provider_class=net.sf.hibernate.cache.OSCacheProvider, hibernate.cglib.use_reflection_optimizer=true, hibernate.connection.pool_size=10, hibernate.show_sql=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory}
- using CGLIB reflection optimizer
- configuring from url: file:/C:/trabajo/workspaces/personal/gastos/classes/com/ntrc/gastos/conf/database/test-database.cfg.xml
- Mapping resource: com/ntrc/gastos/bean/Periodo.hbm.xml
- Mapping class: com.ntrc.gastos.bean.Periodo -> PERIODO
- Configured SessionFactory: null
- processing one-to-many association mappings
- processing one-to-one association property references
- processing foreign key constraints
- Using dialect: net.sf.hibernate.dialect.MySQLDialect
- Use outer join fetching: false
- Using Hibernate built-in connection pool (not for production use!)
- Hibernate connection pool size: 10
- using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/gastos
- connection properties: {user=root, password=}
- Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
- No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
- Use scrollable result sets: true
- Use JDBC3 getGeneratedKeys(): true
- Optimize cache for minimal puts: false
- echoing all SQL to stdout
- Query language substitutions: {}
- cache provider: net.sf.hibernate.cache.OSCacheProvider
- Error reading /oscache.properties in CacheAdministrator.loadProps() java.lang.NullPointerException
- Ensure the /oscache.properties file is readable and in your classpath.
- instantiating and configuring caches
- building session factory
- reflection optimizer disabled for: com.ntrc.gastos.bean.Periodo, IllegalArgumentException: Cannot find matching method/constructor
- no JNDI name configured
---------- BOOT log (App Server) -------------------
Code:
- Hibernate 2.1.3
- loaded properties from resource hibernate.properties: {hibernate.cache.provider_class=net.sf.hibernate.cache.OSCacheProvider, hibernate.cglib.use_reflection_optimizer=true, hibernate.connection.pool_size=10, hibernate.show_sql=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory}
- using CGLIB reflection optimizer
- configuring from url: file:C:/bea/user_projects/myserver/.wlnotdelete/gastos/webapp/WEB-INF/classes/com/ntrc/gastos/conf/database/database.cfg.xml
- Mapping resource: com/ntrc/gastos/bean/Periodo.hbm.xml
- Mapping class: com.ntrc.gastos.bean.Periodo -> PERIODO
- Configured SessionFactory: null
- processing one-to-many association mappings
- processing one-to-one association property references
- processing foreign key constraints
- Using dialect: net.sf.hibernate.dialect.MySQLDialect
- Use outer join fetching: false
- JNDI InitialContext properties:{}
- Using datasource: jdbc/gastosDataSource
- Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
- JNDI InitialContext properties:{}
- No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
- No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
- Use scrollable result sets: true
- Use JDBC3 getGeneratedKeys(): true
- Optimize cache for minimal puts: false
- Query language substitutions: {}
- cache provider: net.sf.hibernate.cache.OSCacheProvider
- Error reading /oscache.properties in CacheAdministrator.loadProps() java.lang.NullPointerException
- Ensure the /oscache.properties file is readable and in your classpath.
- instantiating and configuring caches
- building session factory
- reflection optimizer disabled for: com.ntrc.gastos.bean.Periodo, IllegalArgumentException: Cannot find matching method/constructor
- no JNDI name configured