Ich versuche Hibernate JPA mit einem Derby JDBC Treiber mit "autocommit" zu betreiben. Nach dem Aufruf von persist() für ein neues Objekt wird das Objekt allerdings nicht committed (obwohl der Treiber autocommit eingeschaltet hat - siehe LOG file unten!)
Die Persistence Unit ist wie folgt konfiguriert:
Code:
<persistence-unit name="unit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>contact.Contact</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect" />
<property name="hibernate.connection.url" value="jdbc:derby://localhost:1527/JavaDB;create=true" />
<property name="hibernate.connection.username" value="user1" />
<property name="hibernate.connection.password" value="user1" />
<property name="hibernate.connection.autocommit" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.JDBCTransactionFactory" />
</properties>
</persistence-unit>
Die gleiche Anwendung ohne JPA (also nur Hibernate API) berücksichtigt autocommit es funktioniert also wie erwartet. Die JPA Lösung funktioniert nur wenn der persist() Aufruf mit begin und commit transaction umklammert wird!
Hier meine Frage: benötigt JPA weitere Konfigurationsparameter damit autocommit funktioniert?
Ich verwende hibernate 3.2.1.ga und derby 10.2.2.0.
Zur Unterstützung füge ich noch den Log der JPA Lösung an:
Code:
13:04:46,621 INFO Version:15 - Hibernate EntityManager 3.2.1.GA
13:04:46,636 INFO Version:15 - Hibernate Annotations 3.2.1.GA
13:04:46,652 INFO Environment:500 - Hibernate 3.2.1
13:04:46,652 INFO Environment:533 - hibernate.properties not found
13:04:46,652 INFO Environment:667 - Bytecode provider name : cglib
13:04:46,652 INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
13:04:46,886 WARN Ejb3Configuration:993 - Overriding hibernate.transaction.factory_class is dangerous, this might break the EJB3 specification implementation
13:04:47,042 INFO AnnotationBinder:388 - Binding entity from annotated class: contact.Contact
13:04:47,074 INFO EntityBinder:378 - Bind entity contact.Contact on table Contact
13:04:47,199 INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
13:04:47,199 INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20
13:04:47,199 INFO DriverManagerConnectionProvider:45 - autocommit mode: true
13:04:47,199 WARN DriverManagerConnectionProvider:52 - no JDBC Driver class was specified by property hibernate.connection.driver_class
13:04:47,199 INFO DriverManagerConnectionProvider:80 - using driver: null at URL: jdbc:derby://localhost:1527/JavaDB;create=true
13:04:47,199 INFO DriverManagerConnectionProvider:86 - connection properties: {user=user1, password=****, autocommit=true, release_mode=auto}
13:04:47,402 INFO SettingsFactory:81 - RDBMS: Apache Derby, version: 10.2.2.0 - (485682)
13:04:47,402 INFO SettingsFactory:82 - JDBC driver: Apache Derby Network Client JDBC Driver, version: 10.2.2.0 - (485682)
13:04:47,480 INFO Dialect:151 - Using dialect: org.hibernate.dialect.DerbyDialect
13:04:47,496 INFO TransactionFactoryFactory:34 - Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
13:04:47,496 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
13:04:47,496 INFO SettingsFactory:134 - Automatic flush during beforeCompletion(): disabled
13:04:47,496 INFO SettingsFactory:138 - Automatic session close at end of transaction: disabled
13:04:47,496 INFO SettingsFactory:153 - Scrollable result sets: enabled
13:04:47,496 INFO SettingsFactory:161 - JDBC3 getGeneratedKeys(): disabled
13:04:47,496 INFO SettingsFactory:169 - Connection release mode: auto
13:04:47,496 INFO SettingsFactory:196 - Default batch fetch size: 1
13:04:47,496 INFO SettingsFactory:200 - Generate SQL with comments: disabled
13:04:47,496 INFO SettingsFactory:204 - Order SQL updates by primary key: disabled
13:04:47,496 INFO SettingsFactory:369 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
13:04:47,496 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
13:04:47,496 INFO SettingsFactory:212 - Query language substitutions: {}
13:04:47,496 INFO SettingsFactory:217 - JPA-QL strict compliance: enabled
13:04:47,496 INFO SettingsFactory:222 - Second-level cache: enabled
13:04:47,496 INFO SettingsFactory:226 - Query cache: disabled
13:04:47,496 INFO SettingsFactory:356 - Cache provider: org.hibernate.cache.NoCacheProvider
13:04:47,496 INFO SettingsFactory:241 - Optimize cache for minimal puts: disabled
13:04:47,496 INFO SettingsFactory:250 - Structured second-level cache entries: disabled
13:04:47,511 INFO SettingsFactory:270 - Echoing all SQL to stdout
13:04:47,511 INFO SettingsFactory:277 - Statistics: disabled
13:04:47,511 INFO SettingsFactory:281 - Deleted entity synthetic identifier rollback: disabled
13:04:47,511 INFO SettingsFactory:296 - Default entity-mode: pojo
13:04:47,527 INFO SessionFactoryImpl:161 - building session factory
13:04:47,746 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
13:04:47,933 DEBUG SQL:393 -