I'm new to spring-roo and I want to generate and use my on ids for database entries in a mysql database instead of the auto-generated ids. And I'm not sure how to do this. The only related post I found here is this one:
How can I provide my own @id field using Spring Roo and JPA
But this post is now four years old and I'm using spring roo 1.3.2 instead of 1.1.0 so maybe something changed in the meantime.
So the generated code by spring roo in the test_Roo_Jpa_Entity.aj is:
privileged aspect test_Roo_Jpa_Entity {
declare @type: test: @Entity;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long test.id;
This is also what I see in the database. The id of a new entry is autogenerated and this is something I want to avoid.I played around with the --identifierField or --identifierColumn commands in spring roo but so far without any success. But I'm not sure how to use these commands.
Thank you very much for your help in advance!
EDIT 1:
Code for persit my Entity:
String[] split = line.split(";"); Long TEST_ID = Long.valueOf(split[0]);
String TEST_NAME = split[1]; TEST test = new TEST(); test.setName(TEST_NAME);
test.setId(TEST_ID); test.persist()