[Hibernate-JIRA] Created: (HHH-5024) MetadataContext#registerAttribute does not recognize inherited fields
by Adrian Hummel (JIRA)
MetadataContext#registerAttribute does not recognize inherited fields
---------------------------------------------------------------------
Key: HHH-5024
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5024
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager, metamodel
Affects Versions: 3.5.0-CR-2
Environment: Hibernate 3.5.0-CR-2, JPA Modelgen 1.0.0-CR-1
Reporter: Adrian Hummel
Priority: Critical
Attachments: bugreport.zip
The embeddable class {{CustomerId}} (see attached ZIP) inherits from the base class {{AbstractIdentity}} (annotated with {{@MappedSuperclass}}). The metamodel classes for these two classes are correctly generated:
{code:title=AbstractIdentity_.java|borderStyle=solid}
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(AbstractIdentity.class)
public abstract class AbstractIdentity_ {
public static volatile SingularAttribute<AbstractIdentity, String> id;
}
{code}
and
{code:title=CustomerId_.java|borderStyle=solid}
import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(CustomerId.class)
public abstract class CustomerId_ extends AbstractIdentity_ {
}
{code}
When building the entity manager factory, {{MetadataContext#registerAttribute}} (line 378) tries to resolve the field {{CustomerId_.id}} using {{Class#getDeclaredField}}. This results in a {{NoSuchFieldException}} because the field is declared in the super class {{AbstractIdentity_}}.
Proposed solution: Since all field declarations in the metamodel are public, the {{Class#getField}} method should be used instead.
--
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
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-6825) AuditException with @OneToOne-mappedBy and @PrimaryKeyJoinColumn
by André Pankraz (JIRA)
AuditException with @OneToOne-mappedBy and @PrimaryKeyJoinColumn
----------------------------------------------------------------
Key: HHH-6825
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6825
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 4.0.0.CR5
Environment: JBoss AS 7.1.0 / JDK 1.6.0_29 / Windows 7 64
Reporter: André Pankraz
Both entities are audited:
Person {
@OneToOne(mappedBy = "person")
private Nutzerkonto nutzerkonto;
}
Nutzerkonto {
@OneToOne(optional = false)
@PrimaryKeyJoinColumn
private Person person;
}
Generate Person-audit:
reader.createQuery().forRevisionsOfEntity(Person.class, false, true)
.add(AuditEntity.id().eq(id)) ... .getResultList();
Caused by: org.hibernate.envers.exception.AuditException: This criterion can only be used on a property that is a relation to another property.
at org.hibernate.envers.query.criteria.RelatedAuditExpression.addToQuery(RelatedAuditExpression.java:52) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:94) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:106) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.entities.mapper.relation.OneToOneNotOwningMapper.mapToEntityFromMap(OneToOneNotOwningMapper.java:80) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.entities.mapper.MultiPropertyMapper.mapToEntityFromMap(MultiPropertyMapper.java:115) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:99) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:134) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
at org.hibernate.envers.query.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:102) [hibernate-envers-4.0.0.CR5.jar:4.0.0.CR5]
Exception via:
org.hibernate.envers.query.criteria.RelatedAuditExpression:
public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuilder qb, Parameters parameters) {
String propertyName = propertyNameGetter.get(auditCfg);
RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(auditCfg, entityName, propertyName);
if (relatedEntity == null) {
throw new AuditException("This criterion can only be used on a property that is " +
"a relation to another property.");
} else {
relatedEntity.getIdMapper().addIdEqualsToQuery(parameters, id, null, equals);
}
}
propertyName is null!
triggered via org.hibernate.envers.entities.mapper.relation.OneToOneNotOwningMapper.mapToEntityFromMap:
value = versionsReader.createQuery().forEntitiesAtRevision(entityClass, owningEntityName, revision)
.add(AuditEntity.relatedId(owningReferencePropertyName).eq(primaryKey)).getSingleResult();
OneToOneNotOwningMapper.owningReferencePropertyName is null => this is the major problem here I think and may be connected with @PrimaryKeyJoinColumn. Mapper must choose the primary key and not the join column then.
quick hack:
public OneToOneNotOwningMapper(String owningReferencePropertyName, String owningEntityName,
PropertyData propertyData) {
// HACK for @OneToOne with @PrimaryKeyJoinColumn => null
this.owningReferencePropertyName = owningReferencePropertyName == null ? "id" : owningReferencePropertyName;
should handle this in org.hibernate.envers.configuration.metadata.ToOneRelationMetadataGenerator.addOneToOneNotOwning?! but better the experts... ;)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months
[Hibernate-JIRA] Created: (HHH-6605) Storing information about changes of properties
by Michał Skowronek (JIRA)
Storing information about changes of properties
-----------------------------------------------
Key: HHH-6605
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6605
Project: Hibernate Core
Issue Type: New Feature
Components: envers
Affects Versions: 4.x
Reporter: Michał Skowronek
Users would be able to construct more meaningful audit queries if Envers had an option to store and query information about modifications of individual properties, e.g.:
getAuditReader().createQuery().forRevisionsOfEntity(clazz, false, false)
.add(AuditEntity.id().eq(id)).add(AuditEntity.property(propertyName).hasChanged());
With such a query, user will get only those revisions of (clazz, id), that modified property with propertyName.
Currently, to achieve that, user have to retrieve and compare manually two revisions, which increases complexity and decreases performance.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 2 months