Use a autoincrement with hibernate and Mysql that is not an Id so I can reset it with a trigger
<p>I'm implementing a registry app in which each record is identified with a reference like 01/2016, 02/2016, ... and so on.
In my Entity class, I'm using </p>

<pre><code>@Column(nullable = false)
private int year=Calendar.getInstance().get(Calendar.YEAR);
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int numReception; // this field will reset each year with a trigger.
private String reference; // This field should look like "01/2016", filled by a trigger too.
</code></pre>

<p>The reference field will be filled by a trigger too as a combination : "<strong>numReception/year</strong>".</p>

<p>The problem is that hibernate won't auto-increment something that is not a primary key, and I can't use auto increment inside an embaddable composite key too.
<strong>@prepersist</strong> and <strong>@postPersist</strong> are not working eather because JPA callbacks won't work if you're using the Session API (to be used instead of  triggers).</p>

<p>Any solution to implement an auto increment ? any other suggestions ?</p>