[hibernate-issues] [Hibernate-JIRA] Resolved: (ANN-680) oneToMany relationship, in which the source table column does NOT contain a unique constraint
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Thu Nov 15 08:31:29 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bernard resolved ANN-680.
----------------------------------
Resolution: Rejected
the reference column has to be unique to uniquely identify a given row/entity in your source table.
If you are designing a new model, I would recommend to rethink your db schema, something is wrong (and masochist, naming a non unique column as *_ID is all about pain ;) ). If you're stuck with a legacy model, I imagine that APPLE_ID somehow is unique and the pk of an implicit third entity/table. I would recommend to make it explicit (maybe using a view)
Please use the user forum http://forum.hibernate.org for further questions
> oneToMany relationship, in which the source table column does NOT contain a unique constraint
> ---------------------------------------------------------------------------------------------
>
> Key: ANN-680
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-680
> Project: Hibernate Annotations
> Issue Type: New Feature
> Affects Versions: 3.2.1
> Environment: annotations version 3.2.1.ga, java 1.5
> Reporter: Sabina Schneider
>
> I am particulary interested in generating a oneToMany relationship, in which the source table column does NOT contain a unique constraint. Nevertheless, specifying the referencedColumnName creates a unique constraint. How can I avoid this? This is the code:
> @OneToMany(targetEntity = AppleGenre.class, fetch=FetchType.LAZY)
> @LazyCollection(LazyCollectionOption.EXTRA)
> @JoinTable(name = "APPLE_FEATURE",
> joinColumns = { @JoinColumn(name = "APPLEID", referencedColumnName="APPLE_ID",
> unique=false, nullable=false, insertable=false, updatable=false ) },
> inverseJoinColumns = { @JoinColumn(name = "WORD", referencedColumnName="APPLEGENREID ",
> unique=false, nullable=false, insertable=false, updatable=false) }
> )
> public List<SoftGenre> getSoftGenres(){
> return softGenres;
> }
> APPLE_ID is NOT unique and APPLEGENREID is PK of AppleGenre
--
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