[ROO-3432] entity jpa --versionField "" is ignored Created: 20/Jul/13  Updated: 14/Dec/13  Resolved: 14/Dec/13

Status: Resolved
Project: Spring Roo
Component/s: @ ROO SHELL, PERSISTENCE
Affects Version/s: 1.2.4.RELEASE
Fix Version/s: 1.2.5.RELEASE

Type: Bug Priority: Minor
Reporter: Karl Bennett Assignee: Alan Stewart
Resolution: Complete Votes: 0
Labels: jpa, pull-request-submitted, roo
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux



 Description   

Setting an entities version field name to the empty string is ignored.

roo> project --topLevelPackage roo.jira --projectName roo-3432
roo> jpa setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT
roo> entity jpa --class roo.jira.Entity --versionField ""

The above commands will still produce an entity with a version field.

roo.jira.Entity.java
...
@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class Entity {
}
roo.jira.Entity_Roo_Jpa_Entity.aj
...
privileged aspect Entity_Roo_Jpa_Entity {

    declare @type: Entity: @javax.persistence.Entity;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long Entity.id;

    @Version
    @Column(name = "version")
    private Integer Entity.version;
...


 Comments   
Comment by Karl Bennett [ 20/Jul/13 ]

I have submitted a pull request.

Comment by Alan Stewart [ 17/Aug/13 ]

Merged. Thanks. Please test

Comment by Alan Stewart [ 23/Oct/13 ]

Did you test this?

Comment by Alan Stewart [ 13/Dec/13 ]

Any news?

Comment by Karl Bennett [ 14/Dec/13 ]

Sorry, was waiting for your reply to ROO-3431, but now that I know you meant manual test it I'll do it as soon as I can tomorrow.

I asked in ROO-3431 if you would like me to attempt to write some automated tests for that feature, I'm also happy to attempt it for this one if you wish

Comment by Karl Bennett [ 14/Dec/13 ]

Ok, so it all looks fine to me.

I got the latest code by doing a brand new clone of https://github.com/spring-projects/spring-roo.git.

Running the following commands:

roo> project --topLevelPackage roo.jira --projectName roo-3432
roo> jpa setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT
roo> entity jpa --class roo.jira.Entity --versionField ""

Produces the following entity:

roo.jira.Entity.java
...
@RooJavaBean
@RooToString
@RooJpaActiveRecord(versionField = "")
public class Entity {
}
roo.jira.Entity_Roo_Jpa_Entity.aj
...
privileged aspect Entity_Roo_Jpa_Entity {
    
    declare @type: Entity: @javax.persistence.Entity;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long Entity.id;
    
    public Long Entity.getId() {
        return this.id;
    }
    
    public void Entity.setId(Long id) {
        this.id = id;
    }
    
}

It is also possible to add and remove the version field be regenerating the Entity class.

roo> entity jpa --class ~.Entity
roo> entity jpa --class ~.Entity --versionField ""

I couldn't find any way to add the version field to an existing class, so couldn't test that.

Comment by Alan Stewart [ 14/Dec/13 ]

Thanks. No need for other tests.

Generated at Tue Dec 10 10:24:56 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.