-
Bug
-
Resolution: Done
-
Major
-
7.2.3.GA
I have two entity (Person and Employee) and Employee extends Person. Look this.
@Entity @Inheritance(strategy = InheritanceType.JOINED) public class Person implements Serializable { @Id @GeneratedValue private Long id; @Column private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; return id.equals(person.id); } @Override public int hashCode() { return Objects.hash(id); } }
@Entity public class Employee extends Person { @Column private String role; public String getRole() { return role; } public void setRole(String role) { this.role = role; } }
When I try to persist Employee entity the Person is persisted but the Employee is not persisted. Below is my persistence.xml:
<persistence> <persistence-unit name="javaee8"> <jta-data-source>MSSQLDS</jta-data-source> <properties> <property name="javax.persistence.schema-generation.database.action" value="update" /> </properties> <class>net.rhuanrocha.entity.Employee</class> <class>net.rhuanrocha.entity.Person</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.jdbc.batch_size" value="50" /> <property name="hibernate.connection.isolation" value="2" /> <property name="hibernate.id.new_generator_mappings" value="false" /> <property name="hibernate.hbm2ddl.jdbc_metadata_extraction_strategy" value="individually" /> </properties> </persistence-unit> </persistence>
If I remove the <property name="hibernate.jdbc.batch_size" value="50" /> or use normal ID generation (rather than the legacy generation algorithm) it works fine.
The below was noted in the logs.
14:51:40,743 DEBUG [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) could not log warnings: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_COMMITTED
at org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:248)
at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransactionActive(WrappedConnection.java:1933)
at org.jboss.jca.adapters.jdbc.WrappedConnection.checkStatus(WrappedConnection.java:1948)
at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1922)
at org.jboss.jca.adapters.jdbc.WrappedConnection.getWarnings(WrappedConnection.java:1064)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.handleAndClearWarnings(SqlExceptionHelper.java:290)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logAndClearWarnings(SqlExceptionHelper.java:269)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:194)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.afterStatement(LogicalConnectionManagedImpl.java:149)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterStatementExecution(JdbcCoordinatorImpl.java:279)
at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.releaseStatements(AbstractBatchImpl.java:158)
at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.release(AbstractBatchImpl.java:195)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:184)
at org.hibernate.internal.AbstractSharedSessionContract.close(AbstractSharedSessionContract.java:324)
at org.hibernate.internal.SessionImpl.closeWithoutOpenChecks(SessionImpl.java:432)
at org.hibernate.internal.SessionImpl.close(SessionImpl.java:418)
at org.jboss.as.jpa.transaction.TransactionUtil$SessionSynchronization.safeCloseEntityManager(TransactionUtil.java:181)
at org.jboss.as.jpa.transaction.TransactionUtil$SessionSynchronization.afterCompletion(TransactionUtil.java:163)
at org.jboss.as.txn.service.internal.tsr.JCAOrderedLastSynchronizationList.afterCompletion(JCAOrderedLastSynchronizationList.java:144)
Also noticed that if several entities are persisted in a transaction all but the final entity seem to be persisted correctly.
- is incorporated by
-
JBEAP-17513 [GSS](7.2.z) Upgrade Hibernate ORM from 5.3.11.SP1 to 5.3.13
- Closed
- links to