views:

317

answers:

1

Hi,

I have a legacy table that uses a column that holds a date as the natural prmary key to the table. I am trying to map this with hibernate, but for the life of me I can't figure out how to get hibernate to map a single (none-compound) natural key as the Id.

I have it mapped like this:

@Id
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "HOLIDAY_DATE", unique = true, nullable = false, length = 7)
public Date getHolidayDate() {
    return holidayDate;
}

But hibernate complains that there is "more thatn one attribute configured for getHolidayDate"

What is the proper way to do this?

+1  A: 

Are you sure it's Hibernate that complains and not your IDE?

IntelliJ Idea in particular has been known to complain about both @Id and @Column being specified as annotations for the same method. It is, however, perfectly valid.

If you do get this error from Hibernate (e.g. when you try to initialize a SessionFactory), please post full stack trace as well as your entire class (entity / property annotations)

ChssPly76
I have seen the same problem in Google.
Arthur Ronald F D Garcia