Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:hibernate-3.2
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.c3p0.max_size">5</property>
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="hibernate.cache.use_minimal_puts">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">qazxsw</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/media_server</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.max_fetch_depth">3</property>
<property name="hibernate.show_sql">true</property>
<mapping resource="test/MediaType.hbm.xml" />
<mapping resource="test/Keyword.hbm.xml" />
<mapping resource="test/MediaKeyword.hbm.xml" />
<mapping resource="test/Comment.hbm.xml" />
<mapping resource="test/User.hbm.xml" />
<mapping resource="test/Media.hbm.xml" />
</session-factory>
Code between sessionFactory.openSession() and session.close():
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
List list = session.createQuery("from "+MediaType.class.getSimpleName()).list();
for (Iterator iter = list.iterator(); iter.hasNext();) {
MediaType next = (MediaType) iter.next();
System.out.println(next.getTypeName());
}
session.close();
Full stack trace of any exception that occurs:
INFO [main] (org.hibernate.cfg.Environment.java:500) - Hibernate 3.2.1
INFO [main] (org.hibernate.cfg.Environment.java:533) - hibernate.properties not found
INFO [main] (org.hibernate.cfg.Environment.java:667) - Bytecode provider name : cglib
INFO [main] (org.hibernate.cfg.Environment.java:584) - using JDK 1.4 java.sql.Timestamp handling
INFO [main] (org.hibernate.cfg.Configuration.java:1423) - configuring from resource: /hibernate.cfg.xml
INFO [main] (org.hibernate.cfg.Configuration.java:1400) - Configuration resource: /hibernate.cfg.xml
INFO [main] (org.hibernate.cfg.Configuration.java:553) - Reading mappings from resource : test/MediaType.hbm.xml
INFO [main] (org.hibernate.cfg.HbmBinder.java:300) - Mapping class: test.MediaType -> media_type
INFO [main] (org.hibernate.cfg.Configuration.java:553) - Reading mappings from resource : test/Keyword.hbm.xml
INFO [main] (org.hibernate.cfg.HbmBinder.java:300) - Mapping class: test.Keyword -> keyword
INFO [main] (org.hibernate.cfg.Configuration.java:553) - Reading mappings from resource : test/MediaKeyword.hbm.xml
INFO [main] (org.hibernate.cfg.HbmBinder.java:300) - Mapping class: test.MediaKeyword -> media_keyword
INFO [main] (org.hibernate.cfg.Configuration.java:553) - Reading mappings from resource : test/Comment.hbm.xml
INFO [main] (org.hibernate.cfg.HbmBinder.java:300) - Mapping class: test.Comment -> comment
INFO [main] (org.hibernate.cfg.Configuration.java:553) - Reading mappings from resource : test/User.hbm.xml
INFO [main] (org.hibernate.cfg.HbmBinder.java:300) - Mapping class: test.User -> user
INFO [main] (org.hibernate.cfg.Configuration.java:553) - Reading mappings from resource : test/Media.hbm.xml
INFO [main] (org.hibernate.cfg.HbmBinder.java:300) - Mapping class: test.Media -> media
INFO [main] (org.hibernate.cfg.Configuration.java:1538) - Configured SessionFactory: null
INFO [main] (org.hibernate.connection.C3P0ConnectionProvider.java:50) - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/media_server
INFO [main] (org.hibernate.connection.C3P0ConnectionProvider.java:51) - Connection properties: {user=root, password=****}
INFO [main] (org.hibernate.connection.C3P0ConnectionProvider.java:54) - autocommit mode: false
INFO [main] (com.mchange.v2.log.MLog.java:80) - MLog clients using log4j logging.
INFO [main] (com.mchange.v2.c3p0.C3P0Registry.java:77) - Initializing c3p0-0.9.0 [built 11-July-2005 00:43:29 -0400; debug? true; trace: 10]
INFO [main] (com.mchange.v2.c3p0.PoolBackedDataSource.java:257) - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1f4cbee [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@13e58d4 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 13e58d4, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxIdleTime -> 1800, maxPoolSize -> 5, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@5a67c9 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 5a67c9, jdbcUrl -> jdbc:mysql://localhost/media_server, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 1f4cbee, numHelperThreads -> 3 ]
INFO [main] (org.hibernate.cfg.SettingsFactory.java:81) - RDBMS: MySQL, version: 5.0.20a-max
INFO [main] (org.hibernate.cfg.SettingsFactory.java:82) - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.0.3 ( $Date: 2006-07-26 17:26:47 +0200 (Wed, 26 Jul 2006) $, $Revision: 5553 $ )
INFO [main] (org.hibernate.dialect.Dialect.java:151) - Using dialect: org.hibernate.dialect.MySQLDialect
INFO [main] (org.hibernate.transaction.TransactionFactoryFactory.java:31) - Using default transaction strategy (direct JDBC transactions)
INFO [main] (org.hibernate.transaction.TransactionManagerLookupFactory.java:33) - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO [main] (org.hibernate.cfg.SettingsFactory.java:134) - Automatic flush during beforeCompletion(): disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:138) - Automatic session close at end of transaction: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:145) - JDBC batch size: 15
INFO [main] (org.hibernate.cfg.SettingsFactory.java:148) - JDBC batch updates for versioned data: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:153) - Scrollable result sets: enabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:161) - JDBC3 getGeneratedKeys(): enabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:169) - Connection release mode: auto
INFO [main] (org.hibernate.cfg.SettingsFactory.java:193) - Maximum outer join fetch depth: 3
INFO [main] (org.hibernate.cfg.SettingsFactory.java:196) - Default batch fetch size: 1
INFO [main] (org.hibernate.cfg.SettingsFactory.java:200) - Generate SQL with comments: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:204) - Order SQL updates by primary key: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:369) - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO [main] (org.hibernate.hql.ast.ASTQueryTranslatorFactory.java:24) - Using ASTQueryTranslatorFactory
INFO [main] (org.hibernate.cfg.SettingsFactory.java:212) - Query language substitutions: {}
INFO [main] (org.hibernate.cfg.SettingsFactory.java:217) - JPA-QL strict compliance: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:222) - Second-level cache: enabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:226) - Query cache: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:356) - Cache provider: org.hibernate.cache.NoCacheProvider
INFO [main] (org.hibernate.cfg.SettingsFactory.java:241) - Optimize cache for minimal puts: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:250) - Structured second-level cache entries: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:270) - Echoing all SQL to stdout
INFO [main] (org.hibernate.cfg.SettingsFactory.java:277) - Statistics: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:281) - Deleted entity synthetic identifier rollback: disabled
INFO [main] (org.hibernate.cfg.SettingsFactory.java:296) - Default entity-mode: pojo
INFO [main] (org.hibernate.impl.SessionFactoryImpl.java:161) - building session factory
INFO [main] (org.hibernate.impl.SessionFactoryObjectFactory.java:82) - Not binding factory to JNDI, no JNDI name configured
INFO [main] (org.hibernate.tool.hbm2ddl.SchemaExport.java:154) - Running hbm2ddl schema export
INFO [main] (org.hibernate.tool.hbm2ddl.SchemaExport.java:179) - exporting generated schema to database
INFO [main] (org.hibernate.tool.hbm2ddl.SchemaExport.java:196) - schema export complete
Hibernate:
select
mediatype0_.id_media_type as id1_0_,
mediatype0_.type_name as type2_0_,
mediatype0_.def_image as def3_0_,
mediatype0_.forward_page as forward4_0_
from
media_server.media_type mediatype0_
Name and version of the database you are using:
mySql 5.0.20a-max
no only it doesnt show any data, but it clears from data all tables :(