views:

24

answers:

1

The following is copied from hibernate's document. (http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e2770)

   @CollectionOfElements
    @JoinTable(
            table=@Table(name="BoyFavoriteNumbers"),
            joinColumns = @JoinColumn(name="BoyId")
    )
    @Column(name="favoriteNumber", nullable=false)

However, when I put this in practice, I just found that @JoinTable has no "table" property, instead it has a "name" property to specify the table name. But I need "table" property to specify indexes.

What's going on here? I'm almost driven crazy!

A: 

No, it doesn't, this sample is not accurate. Just in case, the @IndexColumn annotation that you see in this sample has nothing to do with a database index, it is used to store the index number of an element in an indexed collection. But I guess you're aware of that.

Actually, I'd suggest to raise a Jira issue specifying your use case and your database dialect (it seemts that generating an index on the FK works with some dialects, like MySQL, but doesn't with say Oracle).

Pascal Thivent
Thanks a lot! How can hibernate behave like this as such a reputed framwork?
Kent Chen
@Kent Agreed with you. I can think of two causes. 1. Maybe not so much people are really generating the physical model 2. Nobody never reported a complete issue with a testcase (like you should, also pointing out the problem in the doc).
Pascal Thivent