-
1. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 10, 2009 4:28 PM (in response to amin-mc)The following line
referencingPropertyName = role.substring(entityName.length() + 1);
In PersistentCollectionChangeWorkUnit.java is where the exception is thrown.
Cheers -
2. Re: java.lang.StringIndexOutOfBoundsException when using Inh
adamw Feb 11, 2009 2:33 AM (in response to amin-mc)Hello,
this is a known bug with inheritance, fixed in trunk.
--
Adam -
3. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 11, 2009 3:15 AM (in response to amin-mc)Hi
Thanks for your reply. This probably sounds like a silly question but is there a maven release with this fix? Or is there a particular file I can just download and put in my classpath?
Cheers
Amin -
4. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 11, 2009 3:57 AM (in response to amin-mc)Checked out trunk. Seems like a some of the classes I am using have been deprecated and some classes removed. Have to start looking at how to get my stuff working again..
Cheers...I might be back.. -
5. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 11, 2009 1:30 PM (in response to amin-mc)Help! I am trying to update my existing code to use the new code from trunk, however I'm completely lost. I tried the javadocs but unfortunately I cannot find the relevant information.
my original code (part one) looked like thisVersionsReader reader = VersionsReaderFactory.get(hibernateTemplate.getSessionFactory().getCurrentSession()); VersionsOrder versionOrder = dateAsc ? RevisionProperty.asc(): RevisionProperty.desc(); List<?> result = reader.createQuery().forRevisionsOfEntity(entityClass.getClass(),justReturnEntities, true).add(VersionsRestrictions.idEq(entityId)).addOrder(versionOrder).getResultList();
I have tried doing the followingAuditReader auditReader = AuditReaderFactory.get(hibernateTemplate.getSessionFactory().getCurrentSession()); PropertyNameGetter propertyNameGetter = new EntityPropertyName(""); AuditOrder auditOrder = new PropertyAuditOrder(propertyNameGetter, dateAsc); AuditCriterion auditCriterion = AuditEntity.id().eq(entityId); List<?> result = auditReader.createQuery().forRevisionsOfEntity(entityClass.getClass(), justReturnEntities, true).add(auditCriterion).addOrder(auditOrder).getResultList();
However I am not sure what the propertyNameGetter should be.
The second part looked something like thisList<?> entityHistory = showEntityHistory(entityType, id, asc,false); List<BaseHistoryEntity<T>> history = new ArrayList<BaseHistoryEntity<T>>(); for (Object object : entityHistory) { Object[] objArray = (Object[])object; T entity = (T)objArray[0]; DefaultRevisionEntity revision = (DefaultRevisionEntity)objArray[1]; RevisionType revisionType = (RevisionType)objArray[2]; BaseHistoryEntity container = new BaseHistoryEntity(revision.getRevisionDate(), entity, revisionType.name()); history.add(container); } return history;
The base entity class is a holder for information about the entity. I am not sure what the DefaultRevisionEntity should be now. Should be AuditEntity? If so how can i get the revision timestamp and the revision type?
Sorry to be pasting my code but as I mentioned I'm really lost..
Thanks -
6. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 11, 2009 4:36 PM (in response to amin-mc)Hi
It looks like I may have got it all working. My eclipse wasn't picking up some of the old classes.
Cheers -
7. Re: java.lang.StringIndexOutOfBoundsException when using Inh
adamw Feb 12, 2009 4:21 AM (in response to amin-mc)Hello,
that's true, some things changed, but they should work generally the same :). Hope you got it working; to create an order, you can use:AuditEntity.property("surname").desc()
And there are some more examples in the docs:
http://www.jboss.org/files/envers/docs/index.html
--
Adam -
8. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 12, 2009 1:40 PM (in response to amin-mc)Hi Adam...it's ground hog day! I'm experiencing some more problems with inheritence. I am using the latest from trunk and getting the following exception everytime I update my entity class PersonalContact which extends Contact
rg.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: com.amin.app.domain.search.domain.Contact_AUD at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3663) at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1374) at org.hibernate.id.Assigned.generate(Assigned.java:51) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
Both superclass and subclass are annotated with @Audit.
Would it be possible to get some help..hope I don't get barred from the forum! -
9. Re: java.lang.StringIndexOutOfBoundsException when using Inh
adamw Feb 13, 2009 7:38 AM (in response to amin-mc)Hmm ... are you using the correct versions of Hibernate/Envers? :)
That is: trunk Hibernate + trunk Envers or Hibernate 3.3.1 + Envers 3.3.1 branch
--
Adam -
10. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 13, 2009 10:24 AM (in response to amin-mc)Hi Adam
I am using
hibernate core 3.3.1.GA (maven)
and Envers 3.4.0 Snapshot (trunk checked out)
Should i should i build hibernate core from trunk? -
11. Re: java.lang.StringIndexOutOfBoundsException when using Inh
adamw Feb 13, 2009 12:01 PM (in response to amin-mc)Hello,
I think you'll be better off using the Envers-Hibernate 3.3 compatible branch:
http://anonsvn.jboss.org/repos/hibernate/core/branches/envers-hibernate-3.3/
It is in sync with trunk, but also inheritance in 3.3 works.
--
Adam -
12. Re: java.lang.StringIndexOutOfBoundsException when using Inh
amin-mc Feb 13, 2009 3:16 PM (in response to amin-mc)Sweet! Test passing now! Using Envers-Hibernate 3.3
Thanks! I can finally have that beer now...