RE: Tapestry5 and envers (2)
Hi Alejandro, Your email is encouraging in that it confirms envers can be used successfully with Tapestry, though unfortunately I am already using context class 'thread' and the non-proxy hibernate session so must start looking elsewhere for the source of the problem. Can you tell me what version of Tapestry you are using (I am on 5.1.0.5) and whether you are using the Tapestry-Hibernate package or integrating Hibernate yourself? Also, does your getClassDescriptor().getType() method below return a entity.class or a entity_AUD.class - i.e. have you any non-dynamic representations of the *_AUD classes in your application or is envers doing all the work at runtime? Thanks. Regards, Jim. -Original Message- From: Alejandro Scandroli [mailto:alejandroscandr...@gmail.com] Sent: 20 December 2009 16:46 To: Tapestry users Subject: Re: Tapestry5 and envers (2) Hi Jim Are you able to query the audited entities using the AuditReader? Yes, I can create queries using AuditReader. Two questions: 1) Are you using current_session_context_class = thread ? property name=current_session_context_classthread/property 2) Are you using the real Hibernate Session. http://www.mail-archive.com/users@tapestry.apache.org/msg37227.html Here is my code (the relevant part) @Inject private HibernateSessionManager sessionManager; . AuditReader reader = AuditReaderFactory.get(sessionManager.getSession()); AuditQuery query = reader.createQuery().forRevisionsOfEntity(getClassDescriptor().getType(), false, true); query.add(AuditEntity.id().eq(getBeanId())); Saludos. Alejandro. On Sun, Dec 20, 2009 at 2:59 PM, Jim O'Callaghan jc1000...@yahoo.co.uk wrote: Howard, Alejandro, Thanks for looking at the problem. Alejandro, Thanks for the detailed source. I had made local (less elegant!) changes that I think have the same net effect as the changes you have outlined below: - locally modified org.apache.tapestry5.hibernate.HibernateModule.java to not contribute a ValueEncoder for a persistentClass if the class has no MappedClass (I was using .hasPojoRepresentation to decide as I wasn't sure that the lack of a MappedClass should be correctly flagged as an error situation under certain circumstances) - added a section as follows to the existing contributeHibernateSessionSource method within my AppModule: AuditEventListener[] auditEventListener = new AuditEventListener[] {new AuditEventListener()}; configuration.getEventListeners().setPostInsertEventListeners(auditEventListener); configuration.getEventListeners().setPostUpdateEventListeners(auditEventListener); configuration.getEventListeners().setPostDeleteEventListeners(auditEventListener); configuration.getEventListeners().setPreCollectionUpdateEventListeners(auditEventListener); configuration.getEventListeners().setPreCollectionRemoveEventListeners(auditEventListener); configuration.getEventListeners().setPostCollectionRecreateEventListeners(auditEventListener); The type of AuditEventListener above is definitely org.hibernate.envers.event.AuditEventListener. My entities are being audited correctly upon save / update - the problem is when I use org.hibernate.envers.AuditReaderFactory / AuditReader to create a query to return some of the audited entities - this is where the xyz_AUD is not mapped issue occurs. Are you able to query the audited entities using the AuditReader? If you are then perhaps I have some other settings incorrect - I also tried taking out my changes and replacing them with yours, in case there was some subtle difference I was missing, but got the same result. Thanks. Regards, Jim. -Original Message- From: Alejandro Scandroli [mailto:alejandroscandr...@gmail.com] Sent: 19 December 2009 20:05 To: Tapestry users Subject: Re: Tapestry5 and envers (2) Here is how I worked around this problem: First in your AppModule prevent Hibernate from contributing the ValueEncoderSource with this: public static void contributeFactoryDefaults(MappedConfigurationString, String configuration) { configuration.override(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS, false); } Then implement your own contributeValueEncoderSource skipping the ValueEncoder creation if entityClass is null @SuppressWarnings(unchecked) public static void contributeValueEncoderSource(MappedConfigurationClass, ValueEncoderFactory configuration, final HibernateSessionSource sessionSource, final Session session, final TypeCoercer typeCoercer, final PropertyAccess
RE: Tapestry5 and envers (2)
Alejandro, I got this working - thanks for your help. There was an issue to do with Super/sub classes not being annotated with @Audited that contributed to the problem, which clouded the testing once the configuration had been sorted out - thanks. Regards, Jim. -Original Message- From: Jim O'Callaghan [mailto:jc1000...@yahoo.co.uk] Sent: 21 December 2009 10:22 To: Tapestry users Subject: RE: Tapestry5 and envers (2) Hi Alejandro, Your email is encouraging in that it confirms envers can be used successfully with Tapestry, though unfortunately I am already using context class 'thread' and the non-proxy hibernate session so must start looking elsewhere for the source of the problem. Can you tell me what version of Tapestry you are using (I am on 5.1.0.5) and whether you are using the Tapestry-Hibernate package or integrating Hibernate yourself? Also, does your getClassDescriptor().getType() method below return a entity.class or a entity_AUD.class - i.e. have you any non-dynamic representations of the *_AUD classes in your application or is envers doing all the work at runtime? Thanks. Regards, Jim. -Original Message- From: Alejandro Scandroli [mailto:alejandroscandr...@gmail.com] Sent: 20 December 2009 16:46 To: Tapestry users Subject: Re: Tapestry5 and envers (2) Hi Jim Are you able to query the audited entities using the AuditReader? Yes, I can create queries using AuditReader. Two questions: 1) Are you using current_session_context_class = thread ? property name=current_session_context_classthread/property 2) Are you using the real Hibernate Session. http://www.mail-archive.com/users@tapestry.apache.org/msg37227.html Here is my code (the relevant part) @Inject private HibernateSessionManager sessionManager; . AuditReader reader = AuditReaderFactory.get(sessionManager.getSession()); AuditQuery query = reader.createQuery().forRevisionsOfEntity(getClassDescriptor().getType(), false, true); query.add(AuditEntity.id().eq(getBeanId())); Saludos. Alejandro. On Sun, Dec 20, 2009 at 2:59 PM, Jim O'Callaghan jc1000...@yahoo.co.uk wrote: Howard, Alejandro, Thanks for looking at the problem. Alejandro, Thanks for the detailed source. I had made local (less elegant!) changes that I think have the same net effect as the changes you have outlined below: - locally modified org.apache.tapestry5.hibernate.HibernateModule.java to not contribute a ValueEncoder for a persistentClass if the class has no MappedClass (I was using .hasPojoRepresentation to decide as I wasn't sure that the lack of a MappedClass should be correctly flagged as an error situation under certain circumstances) - added a section as follows to the existing contributeHibernateSessionSource method within my AppModule: AuditEventListener[] auditEventListener = new AuditEventListener[] {new AuditEventListener()}; configuration.getEventListeners().setPostInsertEventListeners(auditEventListener); configuration.getEventListeners().setPostUpdateEventListeners(auditEventListener); configuration.getEventListeners().setPostDeleteEventListeners(auditEventListener); configuration.getEventListeners().setPreCollectionUpdateEventListeners(auditEventListener); configuration.getEventListeners().setPreCollectionRemoveEventListeners(auditEventListener); configuration.getEventListeners().setPostCollectionRecreateEventListeners(auditEventListener); The type of AuditEventListener above is definitely org.hibernate.envers.event.AuditEventListener. My entities are being audited correctly upon save / update - the problem is when I use org.hibernate.envers.AuditReaderFactory / AuditReader to create a query to return some of the audited entities - this is where the xyz_AUD is not mapped issue occurs. Are you able to query the audited entities using the AuditReader? If you are then perhaps I have some other settings incorrect - I also tried taking out my changes and replacing them with yours, in case there was some subtle difference I was missing, but got the same result. Thanks. Regards, Jim. -Original Message- From: Alejandro Scandroli [mailto:alejandroscandr...@gmail.com] Sent: 19 December 2009 20:05 To: Tapestry users Subject: Re: Tapestry5 and envers (2) Here is how I worked around this problem: First in your AppModule prevent Hibernate from contributing the ValueEncoderSource with this: public static void contributeFactoryDefaults(MappedConfigurationString, String configuration) { configuration.override(HibernateSymbols.PROVIDE_ENTITY_VALUE_ENCODERS, false); } Then implement your own contributeValueEncoderSource skipping the ValueEncoder creation if entityClass is null @SuppressWarnings(unchecked)
Help with using DWR with Tapestry
Hello, In my project, i would like to use DWR along with Tapestry! But i've a probelm. Its like i need to access the DB, i use Hibernate with Tapestry. In my class i've: @Inject private Session _session; when i access this class from DWR, Tapestry doesn't interfere at all. But, i'm getting a null pointer exception where i first start using the Session. How and what should be done for this? - Ashwanth Kumar