# Seems like @NotFound does not work with @JoinColumns

**URL:** <https://discourse.hibernate.org/t/seems-like-notfound-does-not-work-with-joincolumns/579>\
**Category:** Hibernate ORM\
**Created:** [April 19, 2018, 6:53am UTC](https://discourse.hibernate.org/t/seems-like-notfound-does-not-work-with-joincolumns/579 "2018-04-19T06:53:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@alex](https://discourse.hibernate.org/u/alex)\
**Post date:** [April 19, 2018, 6:53am UTC](https://discourse.hibernate.org/t/seems-like-notfound-does-not-work-with-joincolumns/579/1 "2018-04-19T06:53:19Z")

</div>

Greetings!

Sometimes I have a `NULL` value for FK in my child table.  
So when I try to fetch this row from the parent table I receive this exception:

```auto
java.lang.IllegalArgumentException: Can not set int field com.tsum.entity.Photo.id to **null** value

```

I tried to use `@NotFound` but for `@JoinColumns` it does not work.

Child Entity:

```auto
    @ManyToOne
    @NotFound ( action = NotFoundAction.IGNORE )
    @JoinColumns({
            @JoinColumn(name = "desktop_image_id", referencedColumnName = "id"),
            @JoinColumn(name = "mobile_image_id", referencedColumnName = "id"),
            @JoinColumn(name = "tablet_image_id", referencedColumnName = "id")
    })
    private Photo photo;

```

Parent Entity:

```auto
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private int id;

```

But, for example, when I use this construction for @JoinColumn it works fine:

```auto
    @ManyToOne
    @NotFound ( action = NotFoundAction.IGNORE )
    @JoinColumn(name = "desktop_image_id", referencedColumnName = "id")
    private Photo photo;

```

For temporary workaround I replace type for parent Id from `int` to `Integer` and it works fine for now:

```auto
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Integer id;

```

Please, can anybody explain why this may happen?

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [April 19, 2018, 7:00am UTC](https://discourse.hibernate.org/t/seems-like-notfound-does-not-work-with-joincolumns/579/2 "2018-04-19T07:00:36Z")

</div>

Sounds like a bug. Try to replicate it with [this template](http://in.relation.to/2016/01/14/hibernate-jpa-test-case-template/) and open a Jira issue.
