[Hibernate-JIRA] Created: (HHH-4041) Null Pointer Exception when using @NotAudited on an entity with discriminator column, inherited from base entity with InheritanceType.SINGLE_TABLE
by Priya M (JIRA)
Null Pointer Exception when using @NotAudited on an entity with discriminator column, inherited from base entity with InheritanceType.SINGLE_TABLE
--------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-4041
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4041
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Reporter: Priya M
Using latest Envers version -- 1.2.1GA
This is my mapping:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
class Foo {
}
@Entity
@DiscriminatorValue("bar")
class Bar {
}
@Entity
@Audited
class FooBarTest {
@NotAudited
Bar bar;
}
I get a NPE exception!
Caused by: java.lang.NullPointerException
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateInheritanceMappingData(AuditMetadataGenerator.java:305)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:349)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
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:260)
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)
Right now, I'm forced to make Foo as @Audited even though I don't intend to.
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4090) RelationTargetAuditMode.NOT_AUDITED not working with many-to-many relations
by Jacek Kunicki (JIRA)
RelationTargetAuditMode.NOT_AUDITED not working with many-to-many relations
---------------------------------------------------------------------------
Key: HHH-4090
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4090
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1-GA, PostgreSQL 8.2
Reporter: Jacek Kunicki
When defining a @ManyToMany relation from an @Audited entity to a non-@Audited one using RelationTargetAuditMode.NOT_AUDITED:
@Entity
@Audited
class A {
@ManyToMany
@JoinTable(...)
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private B b;
// getters, setters ...
}
@Entity
class B {
...
}
the following error occurs during deployment:
Caused by: org.hibernate.HibernateException: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
... 145 more
Caused by: org.hibernate.MappingException: An audited relation from A to a non-audited entity: B
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.throwRelationNotAudited(CollectionMetadataGenerator.java:537)
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addValueToMiddleTable(CollectionMetadataGenerator.java:390)
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addWithMiddleTable(CollectionMetadataGenerator.java:310)
at org.hibernate.envers.configuration.metadata.CollectionMetadataGenerator.addCollection(CollectionMetadataGenerator.java:154)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addValue(AuditMetadataGenerator.java:144)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.addProperties(AuditMetadataGenerator.java:164)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateSecondPass(AuditMetadataGenerator.java:419)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:100)
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:260)
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)
--
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, 6 months
[Hibernate-JIRA] Created: (HHH-4658) Possibility to control projection of entities in SQL level when using Criteria queries
by Mindaugas Plukas (JIRA)
Possibility to control projection of entities in SQL level when using Criteria queries
--------------------------------------------------------------------------------------
Key: HHH-4658
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4658
Project: Hibernate Core
Issue Type: Improvement
Components: query-criteria
Affects Versions: 3.3.2
Environment: Oracle 10g
Reporter: Mindaugas Plukas
It is possible to project only desired(root) entity using HQL queries and this projection is reflected into real SQL (when fetching startegy "join fetch" is not employed).
HQL
(1): select [distinct] i from Item i [left|inner] join i.bids b where b.amount > 100
produces SQL
(2): select [distinct] i.* from Item i [left|inner] join BID b on i.ITEM_ID = b.ITEM_ID where b.AMOUNT > 100
On the other hand Criteria query allways selects both entities, even when fetch strategy is "select".
Criteria
(3): session.createCriteria(Item.class).setFetchMode("bids", FetchMode.SELECT)
.createCriteria("bids").add( Restrictions.gt("amount", new BigDecimal(100)))
produces SQL
(4): select i.*, b.* from Item i inner join BID b on i.ITEM_ID = b.ITEM_ID where b.AMOUNT > 100
(and then second SQL to fetch bids, as FetchMode.SELECT implies)
In Criteria query case it seems there is no way to get SQL to select "i.*" only.
This precludes effective selection of distinct Items on SQL level. Also query (1) (with distinct) and select (2) is suitable for setFirstResult()/setMaxResult() processing, however it turns out
that paging can not be used with Criteria (3).
Suggestion would be to introduce special kind of projection "project entity" (equivalent of HQL "select i").
Or maybe setting of result transformer "ROOT_ENTITY" could impact the resulting SQL by limiting SQL's projection to root entity columns (if possible).
This issue may be related to
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2480
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1499
--
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, 6 months