Hi,
I'm trying to do a structural search replace to change annotations. I have getters like
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
public Integer getId() {
return this.id;
}
which I want to replace with
@Id
@SequenceGenerator(name = "fooIdGenerator", sequenceName = "foo_id_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fooIdGenerator")
@Column(name = "id")
public Integer getId() {
return this.id;
}
where foo is the class name.
I tried the following search template and replacement text, and set MethodName as the target of the search. But IDEA tells me that the replacement text is a well formed expression and the search template is not an expression.
search template:
class $CLASS$ {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
$ReturnType$ $MethodName$();
}
replacement text:
@Id
@SequenceGenerator(name = "$CLASS$IdGenerator", sequenceName = "$CLASS$_id_seq")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "$CLASS$IdGenerator")
@Column(name = "id")
$ReturnType$ $MethodName$();
}
Any help would be appreciated.
Regards,
Emerson