title: Can I insert a JPA entity directly using QueryDSL?
body: <p>Is there a way in QueryDSL to insert a JPA entity without using the JPA provider directly?</p>
  
  <p>My use case issue is the following.  I am using Hibernate with a join table mapping between two entities.</p>
  
  <p>Ex:</p>
  
  <pre><code>public class Contract implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "id")
      private Long id;
  
      @Version
      @Column(name = "version")
      private Integer version;
  
      private String number;
      private String volume;
  
      @ManyToMany
      @JoinTable(joinColumns = @JoinColumn(name = "contract_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "attachment_id", referencedColumnName = "id"))
      private List&lt;Attachment&gt; attachments;
  }
  </code></pre>
  
  <p>My problem is that if I try to add attachments in 2 separate threads simultaneously, I will get optimistic lock exceptions (as expected).  So instead, I would like to try to add the attachment directly via an SQL insert command.</p>
  
  <p>Is there anyway of inserting an <code>Attachment</code> entity via QueryDSL as an object?  I couldn't find any reference documentation that covers this use case.  Only an update query, which requires setting the individual fields.</p>
  
  <p>Pseudo code:</p>
  
  <pre><code>JPAQuery.insert(QAttachment.attachment).into(QContract.attachment).where(QContract.contract.id.eq(&lt;contractId&gt;));
  </code></pre>
  
  <p>Is something like this feasible?</p>