I'm working with a table in a database and that table don't have a primary key or a proper column whith a unique value who can act as a primary key, I don't have permissions to alter that table.
What should I do? I tried putting a @id annotation in a random column and it worked, but I don't know if this is going to bring any trouble later on. what can I do?
My class
@Entity
@Table(name="my_table")
public class TheTable {
@Column (name="name", nullable=false)
private String name;
@Id <--- I just put this id in this random column but this column should not be a id column
@Column (name="anyfield", nullable=false)
private String anyfield;
}
I had this problem and was using the wrong import for @id:
Make sure it's:
import javax.persistence.Id;
and not:
import org.springframework.data.annotation.Id;