This content has been marked as final.
Show 6 replies
-
1. Re: issue with @NotAudited and AuditReader queries
ax123man Jun 1, 2009 4:48 PM (in response to ax123man)I should clarify: Asset is audited, Organization isn't. However it's appears I'll need to audit Organization to get this to work.
-
2. Re: issue with @NotAudited and AuditReader queries
adamw Jun 2, 2009 2:22 AM (in response to ax123man)Hello,
if Asset is @Audited, but the association to Organization is @NotAudited, then you shouldn't have to create a join table or audit organization. Doesn't this work? If not, what exception are you getting?
Adam -
3. Re: issue with @NotAudited and AuditReader queries
ax123man Jun 2, 2009 9:27 AM (in response to ax123man)I get this:
Caused by: org.hibernate.HibernateException: Missing table: mte_organization_mte_asset_audit at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1113) at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:349) 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) ... 38 more
that's when I have:<entry key="hibernate.hbm2ddl.auto" value="validate"/>
if I change to "auto=none", I get:org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.loader.Loader.doList(Loader.java:2231) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.envers.query.impl.AbstractAuditQuery.buildAndExecuteQuery(AbstractAuditQuery.java:94) at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:104) at org.hibernate.envers.query.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:100) at org.hibernate.envers.reader.AuditReaderImpl.getRevisions(AuditReaderImpl.java:127) <snip> Caused by: org.postgresql.util.PSQLException: ERROR: relation "mte_organization_mte_asset_audit" does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:258) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1808) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) ... 44 more
-
4. Re: issue with @NotAudited and AuditReader queries
adamw Jun 3, 2009 2:11 AM (in response to ax123man)Looks like a bug then. Could you create a bug in JIRA for this?
Thanks,
Adam -
5. Re: issue with @NotAudited and AuditReader queries
ax123man Jun 3, 2009 8:51 AM (in response to ax123man)done
HHH-3939
thanks adam -
6. Re: issue with @NotAudited and AuditReader queries
ax123man Jun 3, 2009 1:03 PM (in response to ax123man)while implementing the workaround ( auding Organization) I ran into another problem. Organization has this:
@NotAudited @OneToMany(cascade = CascadeType.ALL) @JoinTable(name = "mte_organization_mte_organization", joinColumns = @JoinColumn(name = "parent_organization_id"), inverseJoinColumns = @JoinColumn(name = "child_organization_id")) private List<Organization> organizations = new ArrayList<Organization>();
so because of the original problem, I had to add table mte_organization_mte_organization_audit. But now envers is trying to insert into this table with a null REVTYPE (audit_revision_type in our case):
could not insert: [com.abc.Organization_audit] [insert into mte_organization_mte_organization_audit (child_organization_id, audit_revision_number) values (?, ?)]
org.postgresql.util.PSQLException: ERROR: null value in column "audit_revision_type" violates not-null constraint
what conditions would cause envers to not even have the REVTYPE in the insert?