I'm having trouble with this, too. Note that this is for a "master" base entity and is not part of the model in any way.
Here are the (hopefully) reproduceable steps (done with latest build, 359):
Run the following commands in a new Roo project directory:
Code:
project --topLevelPackage com.abstracttest --projectName abstracttest
persistence setup --database HYPERSONIC_IN_MEMORY --provider HIBERNATE
class --name ~.domain.AbstractBaseEntity --abstract
field number id --type java.lang.Long
field number version --type java.lang.Integer
Exit Roo and "fix up" AbstractBaseEntity with annotations:
Code:
package com.abstracttest.domain;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.Version;
import javax.persistence.GenerationType;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public abstract class AbstractBaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Version
@Column(name = "version")
private Integer version;
}
Re-enter Roo and add a new entity that extends AbstractBaseEntity:
Code:
roo> entity --name ~.domain.Person --extends ~.domain.AbstractBaseEntity
The response I get is this:
Code:
Created SRC_MAIN_JAVA\com\abstracttest\domain\Person.java
Undo create SRC_MAIN_JAVA\com\abstracttest\domain\Person.java
User provided @javax.persistence.Id field but failed to provide a public 'getId()' method in 'com.abstracttest.domain.Person'
roo>
I've also noticed that if I create the Person entity before annotating the AbstractBaseEntity, Roo generates "_id" and "_version" fields on Person_Roo_Entity.aj instead of using the "id" and "version" fields set in AbstractBaseEntity.