[hibernate-issues] [Hibernate-JIRA] Resolved: (ANN-742) Primary key should not be set on nullable column
Hardy Ferentschik (JIRA)
noreply at atlassian.com
Tue Jun 10 10:17:33 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-742?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hardy Ferentschik resolved ANN-742.
-----------------------------------
Resolution: Fixed
There was a actual bug in the code which is fixed now, but the given mapping in the test case was incorrect as well. A bidirectional OneToOne association should be mapped the following way:
@Entity
public class Person {
@Id
private long id;
@OneToOne
@JoinTable(
name = "personAddress",
joinColumns = @JoinColumn(name = "person_id"),
inverseJoinColumns = @JoinColumn(name = "address_id")
)
private Address address;
...
}
@Entity
public class Address {
@Id
private long id;
@OneToOne(mappedBy = "address")
private Person person;
...
}
> Primary key should not be set on nullable column
> ------------------------------------------------
>
> Key: ANN-742
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-742
> Project: Hibernate Annotations
> Issue Type: Bug
> Components: binder
> Affects Versions: 3.3.1.GA
> Environment: hibernate core 3.2.6.GA
> Reporter: Miroslav Havram
> Assignee: Hardy Ferentschik
> Fix For: 3.4.0.CR2
>
> Attachments: create_scripts.zip, test_case.zip
>
>
> After switching to hibernate-annotations 3.3.1.GA, DDL generated for intermediate table for optional one-to-one association tries to set
> primary key on nullable column. Problem is that some DBMSs (e.g. MS SQL) do not allow that.
> Using hibernate-annotations-3.3.0.GA:
> create table personAddress (address_id bigint not null, person_id bigint not null, primary key (person_id))
> Using hibernate-annotations-3.3.1.GA:
> create table personAddress (person_id bigint, address_id bigint, primary key (person_id))
> Simple test case and generated DDLs are attached.
--
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