[hibernate-issues] [Hibernate-JIRA] Moved: (HHH-5174) Problem with @ElementCollection or @CollectionTable in core/annotations 3.5.1 creating bogus unique key

Emmanuel Bernard (JIRA) noreply at atlassian.com
Thu Apr 29 04:45:28 EDT 2010


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bernard moved HCANN-22 to HHH-5174:
--------------------------------------------

        Key: HHH-5174  (was: HCANN-22)
    Project: Hibernate Core  (was: Hibernate Commons Annotations)

> Problem with @ElementCollection or @CollectionTable in core/annotations 3.5.1 creating bogus unique key
> -------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5174
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5174
>             Project: Hibernate Core
>          Issue Type: Bug
>         Environment: Hibernate Core/Annotions 3.5.1-Final
> MySQL 5.1
>            Reporter: Lynn Keeling
>
> I've encountered a problem that may be a hibernate collection bug. Using the code listed below, I'm creating a collection table that has two columns: TERRITORY_ID and characters_CHARACTER_ID. When hibernate creates the table, it creates the following indexes:
> 1. An compound unique index on TERRITORY_ID and characters_CHARACTER_ID, which is expected.
> 2. A non-unique on both TERRITORY_ID and characters_CHARACTER_ID, which is expected.
> 3. A unique index on characters_CHARACTER_ID, WHICH IS THE PROBLEM I"M REPORTING..
> Why is the unique index on characters_CHARACTER_ID being created? If I manually drop the index, my code works fine. Otherwise, I get a unique constraint violation when I try to insert more than one of the same character id into the table. Not the desired behavior. 
> public class Territory implements Serializable {
>     private static final long serialVersionUID = -8906914598601073008L;
>     @Id
>     @Column(name = "TERRITORY_ID", length = 50)
>     private String territoryId;
>     @ElementCollection(fetch = FetchType.LAZY)
>     @CollectionTable(name="TERRITORY_CHARACTER", joinColumns=@JoinColumn(name="TERRITORY_ID"))
>     @Column(name="CHARACTER_ID")
>     private Set<Character> characters;
>     ...
> }
> public class Character implements Serializable {
>     private static final long serialVersionUID = 845127746329423630L;
>     @Id
>     @GeneratedValue(strategy = GenerationType.AUTO)
>     @Column(name = "CHARACTER_ID")
>     private Long characterId;
>     ...
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list