Issue
Question
Can EclipseLink's batch-writing
be used if the entities to be persisted do not use @GeneratedValue
for their primary keys?
I have @IdClass
to use a composite key, and the values are assigned during the instantiation in the code.
Example
@Entity
@Table(name = "myentity")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@IdClass(MyIdClass.class)
public class MyEntity {
@Id
@Column(updatable = false)
private String foo;
@Id
@Column(updatable = false)
private String bar;
@Column
private String whatever;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class MyIdClass implements Serializable {
private String foo;
private String bar;
}
Context
So far, I've been unable to activate EclipseLink's batch-writing
; I just can't get the configuration right.
The few bits of documentation I find online usually seem to mention that it's important to not use @GeneratedValue
with the GenerationType.IDENTITY
, and usually suggest to use one of the two other GenerationType
strategies. However, they don't seem to specifically mention that it's possible to get this to work without using any strategy.
Solution
As Chris said in the comments:
They don't mention it because it wasn't thought to be worth mentioning
So basically: yes, it works just fine.
Answered By - payne