6

I am trying to get Spring Roo to use my own @Id field instead of generating one.

@Entity
...
@RooEntity
@Table(name = "usr")
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "usr_id")
    private Integer id;
    ...
    public Integer getId() { return id; }
    public void setId(Integer id) { this.id = id }
    ...
}

Roo still creates the following in User_Roo_Entity.aj:

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

How can I get it to acknowledge my @Id field? I want to specify my own generator etc.

David Tinker
  • 9,383
  • 9
  • 66
  • 98

1 Answers1

2

Looks like this is a bug in Spring Roo 1.1.0.RELEASE. I changed @Id to @javax.persistence.Id and it works. Explicitly importing javax.persistence.Id also works (instead of just javax.persistence.*). I have optimize imports on in IntelliJ so the first option is probably the best workaround.

David Tinker
  • 9,383
  • 9
  • 66
  • 98
  • Presuming STS, always make sure that the Roo shell is running if you modify entities, so the changes can take effect. – opyate Feb 01 '12 at 15:21