It's my first post, so I hope I do it the right way. I have searched two days for an equivalent Problem, but did not find anything.
Here is what I did: We have an Entity, that contains (beside others) the folowing fields:
@Entity
@Access(AccessType.FIELD)
@Table(name = "component")
public class Component {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
.
.
@OneToMany
@JoinTable(name = "component_dokumentation",
joinColumns = @JoinColumn( name = "component_id" ),
inverseJoinColumns = @JoinColumn(name = "dokumentation_id"))
private Set<FileType> dokumentation;
private Long keySisMf = 0L;
.
.
// Getter and Setter and stuff
}
After one year of usage we have found out, that our Entity became too big and that we have to use DTO Objects to transfer data to the Client, modify them and return them to the Server. For this purpose we modelled an embeddable Entity ComponentAttributes.
So right now it Looks like:
@Entity
@Access(AccessType.FIELD)
@Table(name = "component")
public class Component {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
.
.
@Embedded
private ComponentAttributes componentAttributes;
.
.
}
@Embeddable
@Access(AccessType.FIELD)
public class ComponentAttributes {
private static final long serialVersionUID = 1L;
@OneToMany
@JoinTable(name = "component_dokumentation",
joinColumns = @JoinColumn( name = "component_id" ),
inverseJoinColumns = @JoinColumn(name = "dokumentation_id"))
private Set<FileType> dokumentation;
private Long keySisMf = 0L;
.
.
// Getter and Setter and stuff
}
We did not change anything in the Database. We have encountered Problems in setting values for the set documentation. The field keySisMf is not a Problem. The Problems are just related to the documentation (I must add that FileType is just a Basic Entity consisting of an id and several Strings, so nothing Special). Getting the values and transfering them to the Client is fast and correct. Telling the Server to Change keySisMf is not a Problem. Telling the Server to add or remove a FileType instance simply does not work. No Errors but no changes.
We have logged the JPA generated SQL and there is no SQL generated for component.getComponentAttributes().setDokumentation(fileSet).
We use a Glassfish 4.1.1 Server with an ORACLE Database. Did I miss something when moving dokumentation from Component to ComponentAttributes????
Thanks for your help and patience.
Chris