I'm trying to get the affected rows on insert. I've seen some solution on how to do it but I don't know how to apply it on my code. I'm using spring boot and I haven't mastered it yet. This is my sample code:
Model:
@Entity
@Table(name="test_table")
public class TestTable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "name")
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Repository:
public interface TestTableRepository extends CrudRepository<TestTable, Long> {
}
Service:
public interface TestTableService {
public void saveOrUpdate(TestTable testTable);
}
Service Impl:
@Override
public void saveOrUpdate(TestTable testTable) {
testTableRepository.save(testTable);
}
There are some unique rows so I need to know if it inserted or not.
Hoping you could help me. Thank you