[Hibernate-JIRA] Created: (HHH-4928) Non-Audited Entity with @ManyToOne in PK causes error in Envers 1.2.2
by Jeff Quandt (JIRA)
Non-Audited Entity with @ManyToOne in PK causes error in Envers 1.2.2
---------------------------------------------------------------------
Key: HHH-4928
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4928
Project: Hibernate Core
Issue Type: Bug
Components: envers
Environment: Hibernate 3.3.2, Envers 1.2.2, Oracle 10.2
Reporter: Jeff Quandt
Attachments: enversError.txt
>From http://community.jboss.org/thread/148209?tstart=0:
We've been using Envers 1.2.1.GA w/ Hibernate 3.3.2.GA for some time now. I'm attempting to update to 1.2.2 to make use of the RelationTargetAuditMode.NOT_AUDITED feature. However, simply dropping the new library in place with no code changes gives the attached stack trace. Truncated version below.
Including the RelationTargetAuditMode.NOT_AUDITED parameter or @NotAudited on all audited ManyToOne relationships made no difference.
org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.ioc.spring.contextLoader
...
Caused by: org.hibernate.HibernateException: could not init listeners
...
Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.ManyToOneType
at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addIdProperties(IdMetadataGenerator.java:71)
at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addId(IdMetadataGenerator.java:107)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:380)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:102)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:315)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 173 more
I'm trying to add relationships like below. This relationship, without the targetAuditMode parameter, worked successfully in 1.2.1. SomeEntity was not audited in 1.2.1 and was a static dictionary object, so I didn't have to worry about an Audit join table or an audit table for SomeEntity. The column would be correctly filled in the audit table. However, under 1.2.2 the same code does not deploy.
@ManyToOne( fetch = FetchType.LAZY )
@JoinColumn( name="SOME_ID", nullable=true )
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private SomeEntity someEntity;
Per Adam Warski's reply, this is due to a non-Audited entity with @ManyToOne in the PK. This type of entity does exist in my project.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 1 month
[Hibernate-JIRA] Created: (HHH-4929) SequenceGenerator Not avaliable for BYTE
by Vinicius Silva (JIRA)
SequenceGenerator Not avaliable for BYTE
----------------------------------------
Key: HHH-4929
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4929
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Reporter: Vinicius Silva
I create a class with this annotation
...
@Entity
@Table(name = "BAIRRO", schema = "BLUEGAS")
@SequenceGenerator(name = "seq",sequenceName="SEQ_BAIRRO")
public class Bairro extends ValueObjectImpl implements java.io.Serializable {
private byte id;
private String nome;
private Character situacao;
private Set<Endereco> enderecos = new HashSet<Endereco>(0);
public Bairro() {
}
public Bairro(byte id) {
this.id = id;
}
public Bairro(byte id, String nome, Character situacao, Set<Endereco> enderecos) {
this.id = id;
this.nome = nome;
this.situacao = situacao;
this.enderecos = enderecos;
}
@Id
@Column(name = "ID", unique = true, nullable = false, precision = 2, scale = 0)
@GeneratedValue(generator = "seq", strategy = GenerationType.AUTO)
public byte getId() {
return this.id;
}
...
And this Sequence give me error!
org.hibernate.id.IdentifierGenerationException: this id generator generates long, integer, short or string
Need make this id generator for kind BYTE!!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 1 month
[Hibernate-JIRA] Created: (HHH-4927) Criteria queries on lazily loaded composite (embedded) identifiers fail with StatelessSession
by Chris Wilson (JIRA)
Criteria queries on lazily loaded composite (embedded) identifiers fail with StatelessSession
---------------------------------------------------------------------------------------------
Key: HHH-4927
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4927
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.2
Reporter: Chris Wilson
Attachments: HibernateStatelessSessionCriteriaUniqueKeyJoinTest.java
When performing a org.hibernate.Criteria query in a stateless session, and a PersistentClass links to another using a unique non-primary key reference, the referenced object is not fully populated, only enough to store the linked primary key fields. This makes Hibernate think that it's just loaded a transient object (as the ID is still left null), which it doesn't like at all:
{noformat:title=Exception stack trace}
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.wfp.rita.test.hibernate.HibernateStatelessSessionCriteriaUniqueKeyJoinTest$Project
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:110)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:307)
at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1732)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1703)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1593)
at org.hibernate.loader.Loader.doQuery(Loader.java:696)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1885)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)
at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:108)
at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1662)
at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:641)
at org.hibernate.type.EntityType.resolve(EntityType.java:415)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.StatelessSessionImpl.list(StatelessSessionImpl.java:565)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at org.wfp.rita.test.hibernate.HibernateStatelessSessionCriteriaUniqueKeyJoinTest.assertList(HibernateStatelessSessionCriteriaUniqueKeyJoinTest.java:162)
at org.wfp.rita.test.hibernate.HibernateStatelessSessionCriteriaUniqueKeyJoinTest.testFailingDefaultLazyStatelessSession(HibernateStatelessSessionCriteriaUniqueKeyJoinTest.java:218)
{noformat}
This call chain:
* org.hibernate.type.EntityType.resolve(EntityType.java:415)
* org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
* org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877)
will find the object ({@link Project} or {@link Site}) in the StatefulPersistenceContext if it was eagerly loaded, because it has already been hydrated.
Otherwise, it calls EntityType.loadByUniqueKey() which ends up calling ForeignKeys.getEntityIdentifierIfNotUnsaved(), which calls SessionImplementor.getContextEntityIdentifier() to retrieve the Project or Site's ID, to bind to the query to retrieve the ProjectSite.
If the {@link Session} is stateful, this works fine, because SessionImpl.getContextEntityIdentifier() knows how to retrieve the identifier from the
HibernateProxy even though the object is not loaded yet.
However, StatelessSessionImpl has a lame implementation of getContextEntityIdentifier():
{code}
public Serializable getContextEntityIdentifier(Object object) {
errorIfClosed();
return null;
}
{code}
And because the object is a lazy proxy which has not yet been initialized, its fields are all null, so ForeignKeys#isTransient returns true, and ForeignKeys.getEntityIdentifierIfNotUnsaved() throws the exception shown above.
I think the best fix is to improve the implementation of StatelessSessionImpl.getContextEntityIdentifier() to match the one in SessionImpl. We could instead improve ForeignKeys.isTransient() to check for a proxy object, but I think it makes more sense for there to be more shared code between SessionImpl and StatelessSessionImpl instead. Ideally these should inherit from a common base class or the statefulness should be extracted into a wrapper around a stateless Session instead.
The SessionWrapper class included in the attached test case is used by the included
testSuccessfulWorkaround() test to show that replacing the implementation of StatelessSessionImpl.getContextEntityIdentifier() will fix the problem. It can also be used to work around the problem without patching Hibernate, until the official fix is released.
Change HibernateTestBase to org.hibernate.test.annotations.TestCase to run under Hibernate.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 1 month
[Hibernate-JIRA] Created: (HHH-4926) Upgrade to jDocBook 2.2.1
by Hardy Ferentschik (JIRA)
Upgrade to jDocBook 2.2.1
-------------------------
Key: HHH-4926
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4926
Project: Hibernate Core
Issue Type: Bug
Components: build
Affects Versions: 3.5.0-CR-1
Reporter: Hardy Ferentschik
Assignee: Hardy Ferentschik
Fix For: 3.5.0-CR-2
Without upgrading I get the following error when trying to build the manual:
{code}
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate Manual
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [enforcer:enforce {execution: enforce-java}]
[INFO] [jdocbook:resources {execution: default-resources}]
[INFO] Expanding: /Users/hardy/tmp/m2/org/jboss/jbossorg-jdocbook-style/1.1.0/jbossorg-jdocbook-style-1.1.0.jdocbook-style into /Users/hardy/work/hibernate/core/trunk/documentation/manual/target/docbook/staging
[INFO] Expanding: /Users/hardy/tmp/m2/org/jboss/jbossorg-fonts/1.0.0/jbossorg-fonts-1.0.0.jdocbook-style into /Users/hardy/work/hibernate/core/trunk/documentation/manual/target/docbook/staging
[INFO] Expanding: /Users/hardy/tmp/m2/org/hibernate/hibernate-jdocbook-style/2.0.0/hibernate-jdocbook-style-2.0.0.jdocbook-style into /Users/hardy/work/hibernate/core/trunk/documentation/manual/target/docbook/staging
[INFO] Expanding: /Users/hardy/tmp/m2/org/jboss/jbossorg-jdocbook-style/1.1.0/jbossorg-jdocbook-style-1.1.0.jdocbook-style into /Users/hardy/work/hibernate/core/trunk/documentation/manual/target/docbook/staging
[INFO] Expanding: /Users/hardy/tmp/m2/org/jboss/jbossorg-fonts/1.0.0/jbossorg-fonts-1.0.0.jdocbook-style into /Users/hardy/work/hibernate/core/trunk/documentation/manual/target/docbook/staging
[INFO] [jdocbook:translate {execution: default}]
[Fatal Error] HIBERNATE_-_Relational_Persistence_for_Idiomatic_Java.ent:1:3: The markup in the document preceding the root element must be well-formed.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unexpected problem
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 1 month