# Filter on attribute source entity

**URL:** <https://discourse.hibernate.org/t/filter-on-attribute-source-entity/4329>\
**Category:** Hibernate ORM\
**Created:** [June 24, 2020, 12:38pm UTC](https://discourse.hibernate.org/t/filter-on-attribute-source-entity/4329 "2020-06-24T12:38:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![baptiste](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@baptiste](https://discourse.hibernate.org/u/baptiste)\
**Post date:** [June 24, 2020, 12:38pm UTC](https://discourse.hibernate.org/t/filter-on-attribute-source-entity/4329/1 "2020-06-24T12:38:01Z")

</div>

Hi !

I have an entity like below :

```auto
@Table(name = "t_gti_interlocuteur")
public class Interlocuteur extends AbstractEntity{

   …

	@Column(name = "co_entite_liee", length = 3)
	private String codeEntiteLiee;

	@OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_rcu_entite_liee", referencedColumnName = "id_rcu_tiers", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none"))
	private Tiers tiers;

}

```

The entity “Interlocuteur” can be joined to entity “Tiers”. There is no foreign key between these entities (eg @ForeignKey(name = “none”) ).

But the join must be done only if attribute “co\_entite\_liee” of entity “Interlocteur” is equals to ‘TIE’.

How can I define with annotations this restriction ?

Thanks
