I have created an entity using "new persistent class jpa", I then modified the entity to use a last updated field as the version by adding the following to the .java file generated for the entity:
This updated all the .aj files correctly, but then I used "new integration test" to generate an integration test, and in the Roo_IntegrationTest.aj file two of the generate methods were:Code:@Version @NotNull @Temporal(TemporalType.TIMESTAMP) @Column(name="UPDATE_DATE", nullable=false) private Date updateDate; public java.util.Date getUpdateDate() { return this.updateDate; } public void setUpdateDate(java.util.Date updateDate) { this.updateDate = updateDate; }
The on the last line of each method, the code which reads:Code:@org.junit.Test @org.springframework.transaction.annotation.Transactional public void testFlush() { junit.framework.Assert.assertNotNull("Data on demand for 'Cycle' failed to initialize correctly", dod.getRandomCycle()); java.lang.Long id = dod.getRandomCycle().getId(); junit.framework.Assert.assertNotNull("Data on demand for 'Cycle' failed to provide an identifier", id); gov.ny.dec.saeas.Cycle obj = gov.ny.dec.saeas.Cycle.findCycle(id); junit.framework.Assert.assertNotNull("Find method for 'Cycle' illegally returned null for id '" + id + "'", obj); boolean modified = dod.modifyCycle(obj); java.util.Date currentVersion = obj.getUpdateDate(); obj.flush(); junit.framework.Assert.assertTrue("Version for 'Cycle' failed to increment on flush directive", obj.getUpdateDate() > currentVersion || !modified); } @org.junit.Test @org.springframework.transaction.annotation.Transactional public void testMerge() { junit.framework.Assert.assertNotNull("Data on demand for 'Cycle' failed to initialize correctly", dod.getRandomCycle()); java.lang.Long id = dod.getRandomCycle().getId(); junit.framework.Assert.assertNotNull("Data on demand for 'Cycle' failed to provide an identifier", id); gov.ny.dec.saeas.Cycle obj = gov.ny.dec.saeas.Cycle.findCycle(id); junit.framework.Assert.assertNotNull("Find method for 'Cycle' illegally returned null for id '" + id + "'", obj); boolean modified = dod.modifyCycle(obj); java.util.Date currentVersion = obj.getUpdateDate(); obj.merge(); obj.flush(); junit.framework.Assert.assertTrue("Version for 'Cycle' failed to increment on merge and flush directive", obj.getUpdateDate() > currentVersion || !modified); }
Should be:Code:obj.getUpdateDate() > currentVersion
A work around is to copy the methods to the .java file and make the required change, which will remove the methods from the .aj file. I will log a Jira issue for this.Code:obj.getUpdateDate().after(currentVersion)


Reply With Quote
. Thanks for opening the Jira ticket to track this.
