I got a simple SessionEntity:
public class SessionEntity {
...
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NonNull
@ManyToOne
@JoinColumn(name = "customer_id", nullable = false)
CustomerEntity customerEntity;
...
}
And CustomerEntity:
public class CustomerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NonNull
private String territory;
@NonNull
private String code;
}
After the first transaction, I want to update SessionEntity with new CustomerEntity data using method:
@Query("update SessionEntity session "
+ "set session.customerEntity =:customerEntity "
+ "where "
+ "session.id =:sessionId")
Option<SessionEntity> updateCustomerForSession(@Param("sessionId") String sessionId, @Param("customerEntity") CustomerEntity customerEntity);
But nothing happen and in Postgres, I got still the same customer_id. Also, method one level above is public and @Transactional (SessionRepository - java class).
What is wrong with this solution?