I am fairly new to Hibernate and apparantly really dumb because I have the book and followed the online guide and still can't get it to update my database. I can select records just fine, but it will not save anything.
I apologize if this has been answered before. I saw something similar on
http://forum.hibernate.org/viewtopic.php?t=932154&highlight=flush but the answer they gave (mutable="false") did not work as I am not doing this anywhere. I also saw a question about this in the FAQ, but all it said was to call commit() or flush(), and I am already calling commit(). What am I doing wrong?
Hibernate version:
3.1.2
Mapping documents:
Event.hbm.xml
Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.flush();
session.getTransaction().commit();
Full stack trace of any exception that occurs:
no exceptions!!
Name and version of the database you are using:
HSQL (org.hsqldb.jdbcDriver)
The generated SQL (show_sql=true):
Hibernate: select max(EVENT_ID) from EVENT
Hibernate: insert into EVENT (EVENT_DATE, TITLE, EVENT_ID) values (?, ?, ?)
I am using netBeans, this is what it gives me...
init:
deps-jar:
compile:
10:04:17,265 INFO Environment:479 - Hibernate 3.1.2
10:04:17,281 INFO Environment:509 - hibernate.properties not found
10:04:17,281 INFO Environment:525 - using CGLIB reflection optimizer
10:04:17,296 INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
10:04:17,375 INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
10:04:17,375 INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
10:04:17,546 INFO Configuration:469 - Reading mappings from resource: events/Event.hbm.xml
10:04:17,703 INFO HbmBinder:309 - Mapping class: events.Event -> EVENT
10:04:17,734 INFO Configuration:1419 - Configured SessionFactory: null
10:04:17,828 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
10:04:17,828 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
10:04:17,828 INFO DriverManagerConnectionProvider:45 - autocommit mode: false
10:04:17,859 INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:/data/testdb
10:04:17,859 INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
10:04:18,359 INFO SettingsFactory:77 - RDBMS: HSQL Database Engine, version: 1.8.0
10:04:18,359 INFO SettingsFactory:78 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
10:04:18,406 INFO Dialect:103 - Using dialect: org.hibernate.dialect.HSQLDialect
10:04:18,437 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
10:04:18,437 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
10:04:18,437 INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
10:04:18,437 INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
10:04:18,437 INFO SettingsFactory:136 - JDBC batch size: 15
10:04:18,437 INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
10:04:18,437 INFO SettingsFactory:144 - Scrollable result sets: enabled
10:04:18,437 INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
10:04:18,437 INFO SettingsFactory:160 - Connection release mode: auto
10:04:18,453 INFO SettingsFactory:187 - Default batch fetch size: 1
10:04:18,453 INFO SettingsFactory:191 - Generate SQL with comments: disabled
10:04:18,453 INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
10:04:18,453 INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
10:04:18,453 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
10:04:18,453 INFO SettingsFactory:203 - Query language substitutions: {}
10:04:18,453 INFO SettingsFactory:209 - Second-level cache: enabled
10:04:18,453 INFO SettingsFactory:213 - Query cache: disabled
10:04:18,453 INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
10:04:18,468 INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
10:04:18,468 INFO SettingsFactory:237 - Structured second-level cache entries: disabled
10:04:18,468 INFO SettingsFactory:257 - Echoing all SQL to stdout
10:04:18,468 INFO SettingsFactory:264 - Statistics: disabled
10:04:18,468 INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
10:04:18,468 INFO SettingsFactory:283 - Default entity-mode: pojo
10:04:18,546 INFO SessionFactoryImpl:153 - building session factory
10:04:18,984 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
Hibernate: select max(EVENT_ID) from EVENT
Hibernate: insert into EVENT (EVENT_DATE, TITLE, EVENT_ID) values (?, ?, ?)
My Event
3
10:04:19,171 INFO SessionFactoryImpl:728 - closing
10:04:19,171 INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:hsqldb:file:/data/testdb
debug:
BUILD SUCCESSFUL (total time: 6 seconds)
<class name="events.Event" table="EVENT">
<id name="id" column="EVENT_ID">
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title" column="TITLE"/>
</class>
Any help would be appreciated!! thx