# Envers and proxies for foreign key

**URL:** <https://discourse.hibernate.org/t/envers-and-proxies-for-foreign-key/4557>\
**Category:** Hibernate ORM\
**Created:** [September 9, 2020, 12:31pm UTC](https://discourse.hibernate.org/t/envers-and-proxies-for-foreign-key/4557 "2020-09-09T12:31:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpkeerthi](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/kpkeerthi/32/1186_2.png) [@kpkeerthi](https://discourse.hibernate.org/u/kpkeerthi)\
**Post date:** [September 9, 2020, 12:31pm UTC](https://discourse.hibernate.org/t/envers-and-proxies-for-foreign-key/4557/1 "2020-09-09T12:31:19Z")

</div>

So my entity has multiple @ManyToOne foreign keys:

```auto
@Entity
public class MyEntity {
 
    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;

    @ManyToOne(fetch = LAZY)
    private FK1 fk1;

    @ManyToOne(fetch = LAZY)
    private FK2 fk2;

    @ManyToOne(fetch = LAZY)
    private FK3 fk3;
}

```

While persisting I initialize fk1, fk2 and fk3 using respective entity proxy (entityManager.getReference()) and as a result only INSERT gets fired and no SELECTs were fired for each of the FKs.

But when I enable auditing for the entity, Hibernate Envers appears to be firing 3 SELECTs, one for each FK, at the time it INSERTs into the AUDIT tables.

```auto
@Entity
@Audited(targetAuditMode = NOT_AUDITED)
public class MyEntity {
...

```

How do I prevent this from happening? Is there way to tell Envers to initialize the FKs with entity proxies?
