Hi, I have a problem saving objects into InnoDB MySQL database using JTA transactions within my JBoss and Hibernate Entitymanager environment. No exceptions or/and errors were thrown. The object is constructed correct in memory, but no saving to database does happen...
My current workbench looks like this:
JDK v1.5.0_10
MySQL v5.0.27 (InnoDB)
MySQL JConnector v3.1.14
JBoss v4.0.5GA (EJB3.0 RC9 / Hibernate EntityManager v3.2.0GA)
NetBeans v5.5
Here a piece of the console stack trace of project deployment (everything looks fine, I think):
Code:
[EARDeployer] Init J2EE application: file:/D:/Verzeichnis/_JBoss_/server/default_ejb3/deploy/BenchmarkEJB3.ear
[Ejb3Deployment] EJB3 deployment time took: 2073
[JmxKernelAbstraction] installing MBean: persistence.units:ear=BenchmarkEJB3.ear,jar=BenchmarkEJB3-ejb.jar,unitName=BenchmarkEJB3-ejbPU with dependenci
[JmxKernelAbstraction] jboss.jca:name=BenchmarkDS,service=ManagedConnectionFactory
[Version] Hibernate EntityManager 3.2.0.GA
[Version] Hibernate Annotations 3.2.0.GA
[Environment] Hibernate 3.2.0
[Environment] hibernate.properties not found
[Environment] Bytecode provider name : javassist
[Environment] using JDK 1.4 java.sql.Timestamp handling
[Ejb3Configuration] found EJB3 Entity bean: benchmark.database.entities.Entity0
[Ejb3Configuration] found EJB3 Entity bean: benchmark.database.entities.Entity1
[Ejb3Configuration] found EJB3 Entity bean: benchmark.database.entities.Entity2
[Ejb3Configuration] Persistence provider caller does not implements the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
[Configuration] Reading mappings from resource: META-INF/orm.xml
[Ejb3Configuration] [PersistenceUnit: BenchmarkEJB3-ejbPU] no META-INF/orm.xml found
[AnnotationBinder] Binding entity from annotated class: benchmark.database.entities.Entity0
[EntityBinder] Bind entity benchmark.database.entities.Entity0 on table Entity0
[AnnotationBinder] Binding entity from annotated class: benchmark.database.entities.Entity1
[EntityBinder] Bind entity benchmark.database.entities.Entity1 on table Entity1
[AnnotationBinder] Binding entity from annotated class: benchmark.database.entities.Entity2
[EntityBinder] Bind entity benchmark.database.entities.Entity2 on table Entity2
[CollectionBinder] Mapping collection: benchmark.database.entities.Entity0.entities0_1N -> Entity0
[CollectionBinder] Mapping collection: benchmark.database.entities.Entity1.entities1_1N -> Entity1
[ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
[InjectedDataSourceConnectionProvider] Using provided datasource
[SettingsFactory] RDBMS: MySQL, version: 5.0.27-community-nt
[SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.14 ( $Date: 2006-10-18 17:40:15 +0200 (Wed, 18 Oct 2006) $, $Rev
[Dialect] Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
[TransactionFactoryFactory] Transaction strategy: org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
[TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
[TransactionManagerLookupFactory] instantiated TransactionManagerLookup
[SettingsFactory] Automatic flush during beforeCompletion(): disabled
[SettingsFactory] Automatic session close at end of transaction: disabled
[SettingsFactory] JDBC batch size: 15
[SettingsFactory] JDBC batch updates for versioned data: disabled
[SettingsFactory] Scrollable result sets: enabled
[SettingsFactory] JDBC3 getGeneratedKeys(): enabled
[SettingsFactory] Connection release mode: auto
[SettingsFactory] Maximum outer join fetch depth: 2
[SettingsFactory] Default batch fetch size: 1
[SettingsFactory] Generate SQL with comments: disabled
[SettingsFactory] Order SQL updates by primary key: disabled
[SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
[SettingsFactory] Query language substitutions: {}
[SettingsFactory] JPA-QL strict compliance: enabled
[SettingsFactory] Second-level cache: disabled
[SettingsFactory] Query cache: disabled
[SettingsFactory] Optimize cache for minimal puts: disabled
[SettingsFactory] Structured second-level cache entries: disabled
[SettingsFactory] Statistics: disabled
[SettingsFactory] Deleted entity synthetic identifier rollback: disabled
[SettingsFactory] Default entity-mode: pojo
[SessionFactoryImpl] building session factory
[SessionFactoryObjectFactory] Factory name: java:hibernate/HibernateFactory
[NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jb
[NamingHelper] Creating subcontext: java:hibernate
[SessionFactoryObjectFactory] Bound factory to JNDI name: java:hibernate/HibernateFactory
[SessionFactoryObjectFactory] InitialContext did not implement EventContext
[NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jb
[JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=BenchmarkEJB3.ear,jar=BenchmarkEJB3-ejb.jar,name=BenchmarkSessionBean,service=EJB3 with depende
[EJBContainer] STARTED EJB: ejb.BenchmarkSessionBean ejbName: BenchmarkSessionBean
[EJB3Deployer] Deployed: file:/D:/Verzeichnis/_JBoss_/server/default_ejb3/tmp/deploy/tmp57692BenchmarkEJB3.ear-contents/BenchmarkEJB3-ejb.jar
[TomcatDeployer] deploy, ctxPath=/BenchmarkEJB3-war, warUrl=.../tmp/deploy/tmp57692BenchmarkEJB3.ear-contents/BenchmarkEJB3-war-exp.war/
[EARDeployer] Started J2EE application: file:/D:/Verzeichnis/_JBoss_/server/default_ejb3/deploy/BenchmarkEJB3.ear
Here is my persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="BenchmarkEJB3-ejbPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:BenchmarkDS</jta-data-source>
<properties>
<property name="hibernate.session_factory_name" value="java:hibernate/HibernateFactory"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
<property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
</properties>
</persistence-unit>
</persistence>
Here my simple code within my JavaEE5 project:
Code:
@PersistenceContext(name="BenchmarkEJB3-ejbPU") EntityManager entityManager;
Entity0 entity0 = new Entity0();
entity0.setAttribute0(123456);
entityManager.persist(entity0);
And here is my hibernate tools generated annotated Entity0 class:
Code:
package benchmark.database.entities;
// Generated 20.11.2006 18:31:39 by Hibernate Tools 3.2.0.beta8
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
* Entity0 generated by hbm2java
*/
@Entity
@Table(name="Entity0"
)
public class Entity0 implements java.io.Serializable {
// Fields
private int idEntity0;
private long attribute0;
private Entity0 entity0_N1;
private Set<Entity0> entities0_1N = new HashSet<Entity0>(0);
private Set<Entity1> entities1_0_MN = new HashSet<Entity1>(0);
private Set<Entity1> entities1_1_MN = new HashSet<Entity1>(0);
// Constructors
/** default constructor */
public Entity0() {
}
/** minimal constructor */
public Entity0(long attribute0) {
this.attribute0 = attribute0;
}
/** full constructor */
public Entity0(long attribute0, Entity0 entity0_N1, Set<Entity0> entities0_1N, Set<Entity1> entities1_0_MN, Set<Entity1> entities1_1_MN) {
this.attribute0 = attribute0;
this.entity0_N1 = entity0_N1;
this.entities0_1N = entities0_1N;
this.entities1_0_MN = entities1_0_MN;
this.entities1_1_MN = entities1_1_MN;
}
// Property accessors
@Id @GeneratedValue
@Column(name="idEntity0", unique=false, nullable=false, insertable=true, updatable=true)
public int getIdEntity0() {
return this.idEntity0;
}
public void setIdEntity0(int idEntity0) {
this.idEntity0 = idEntity0;
}
@Column(name="attribute0", unique=false, nullable=false, insertable=true, updatable=true)
public long getAttribute0() {
return this.attribute0;
}
public void setAttribute0(long attribute0) {
this.attribute0 = attribute0;
}
@ManyToOne(cascade={},
fetch=FetchType.LAZY)
@JoinColumn(name="fk_idEntity0_N1", unique=false, nullable=true, insertable=true, updatable=true)
public Entity0 getEntity0_N1() {
return this.entity0_N1;
}
public void setEntity0_N1(Entity0 entity0_N1) {
this.entity0_N1 = entity0_N1;
}
@OneToMany(cascade={}, fetch=FetchType.LAZY, mappedBy="entity0_N1")
public Set<Entity0> getEntities0_1N() {
return this.entities0_1N;
}
public void setEntities0_1N(Set<Entity0> entities0_1N) {
this.entities0_1N = entities0_1N;
}
@ManyToMany(cascade={}, fetch=FetchType.LAZY, mappedBy="entities0_0_NM")
public Set<Entity1> getEntities1_0_MN() {
return this.entities1_0_MN;
}
public void setEntities1_0_MN(Set<Entity1> entities1_0_MN) {
this.entities1_0_MN = entities1_0_MN;
}
@ManyToMany(cascade={}, fetch=FetchType.LAZY, mappedBy="entities0_1_NM")
public Set<Entity1> getEntities1_1_MN() {
return this.entities1_1_MN;
}
public void setEntities1_1_MN(Set<Entity1> entities1_1_MN) {
this.entities1_1_MN = entities1_1_MN;
}
}
After testing, object "entity0" is not saved to database, does anybody faced the same problem & can help?! Thx!