title: Hibernate date field with a unique constraint on the day
body: <p>I'm currently implementing a historical report store where users will store only 1 report per day. We're trying to apply unique constraints but we're struggling as the created date goes down to millisecond resolution. Is there anyway to apply a constraint to just the day of a Date field in Hibernate without having to drop down to apply the constraint directly in our underlying Postgres DB?</p>
  
  <p>The code that doesn't work currently looks like:</p>
  
  <pre><code>@Entity
  @Table(name = "report", uniqueConstraints = @UniqueConstraint(columnNames={"createdDate", "name"})) 
  public class Report {
  
    @Column
    private Date createdDate
  
    @Column   
    private String name;
  
    @Id   
    @GeneratedValue(strategy = GenerationType.SEQUENCE)   
    private Long id;
  
  }
  </code></pre>