0

Let's start with an entity with an embedded structure.

@Entity
public class MyEntity implements Serializable {

  @Embedded private MyEmbeddedObject myEmbeddedObject;

  ...
}

@Embeddable
public class MyEmbeddedObject implements Serializable {

  @Column(name = "first_col", precision = 38, scale = 18)
  private Double firstCol;

  ...
}

The content here is not important. These objects are created in a Java FX application. Once created or modified, they are stored in a database using JPA repositories.

I've observed the following behavior and would like to know if this is normal:

  1. When an object MyEntity is created the very first time from my Java FX interface, JPA will store everything properly in the database, which is the expected behavior.
  2. When I try to modify firstCol from the interface, this modification is displayed properly but its value will not be stored unless MyEmbeddedObject is a protected variable of MyObject. If MyEmbeddedObject is private, it becomes unmodifiable. Values can always be displayed but cannot be modified.

Anyone has any ideas why? This is not a blocking situation because I have a workaround. I'm curious if someone knows if this behavior is normal.

Clifford
  • 88,407
  • 13
  • 85
  • 165
Francois
  • 586
  • 2
  • 6
  • 19
  • Once you modify `firstCol` value, do you save it again into database? Did you try: [saveandflush](https://www.baeldung.com/spring-data-jpa-save-saveandflush) – Valijon Sep 30 '19 at 22:04
  • @Valijon To answer your question, of course I try to save it into database. As I mentioned, everything works well when a new object is created and saved into database with a private embedded object. – Francois Oct 01 '19 at 11:58

0 Answers0